代码原文地址: https://gallery.technet.microsoft.com/scriptcenter/Get-TimeZone-PowerShell-4f1a34e6

<#
.Synopsis
This script retreives the timezone of a local or remote computer via WMI.
.DESCRIPTION
This script retreives the timezone of a local or remote computer via WMI.
.NOTES
Created by: Jason Wasser
Modified: 9/11/2015 03:27:30 PM Changelog:
* Added credential support.
* Simplified code as per suggestions from Jeffrey Hicks @JeffHicks
.EXAMPLE
Get-TimeZone
Shows the localhost timezone.
.EXAMPLE
Get-TimeZone -ComputerName SERVER1
Shows the timezone of SERVER1.
.EXAMPLE
Get-TimeZone -ComputerName (Get-Content c:\temp\computerlist.txt)
Shows the timezone of a list of computers.
.LINK
https://gallery.technet.microsoft.com/scriptcenter/Get-TimeZone-PowerShell-4f1a34e6
#> #Get-TimeZone -ComputerName (Get-Content d:\computerlist20160407.txt) Function Get-TimeZone {
[CmdletBinding()]
[Alias()]
Param
(
# Computer name
[Alias('Name')]
[Parameter(Mandatory=$false,
ValueFromPipeLine=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string[]]$ComputerName=$env:COMPUTERNAME,
$Credential = [System.Management.Automation.PSCredential]::Empty
)
Begin
{
}
Process
{
foreach ($Computer in $ComputerName) {
try {
$ServerInfo = Get-WmiObject -Class win32_timezone -ComputerName $Computer -ErrorAction Stop -Credential $Credential
$cn = $ServerInfo.__SERVER
$TimeZone = $ServerInfo.Caption
}
catch {
$TimeZone = $_.Exception.Message
}
finally {
$propHash = @{
Computername = $Computer
TimeZone = $TimeZone
}
$objTimeZone = New-Object -type PSObject -Property $propHash
$objTimeZone
}
}
}
End
{
}
}

Powershell Function Get-TimeZone的更多相关文章

  1. Powershell Function Get-PendingReboot

    获取系统中Restart Pending的计算机 $servers=get-content D:\serverlist.txt Get-PendingReboot -ComputerName $ser ...

  2. 【Azure 应用服务】Azure Function 启用 Managed Identity后, Powershell Funciton出现 ERROR: ManagedIdentityCredential authentication failed

    问题描述 编写Powershell Function,登录到China Azure并获取Azure AD User信息,但是发现遇见了 [Error] ERROR: ManagedIdentityCr ...

  3. 如何通过PowerShell在Visual Studio的Post-build中预热SharePoint站点

    问题现象 Visual Studio在开发SharePoint的时候,发布部署包后,首次打开及调试站点页面的时候会非常的慢 解决方案 使用PowerShell脚本,加载SharePoint插件后遍历所 ...

  4. SharePoint自动化系列——Manage "Site Subscriptions" using PowerShell

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 你可以将普通的sites加入到你的site subscriptions中,前提是你需要有一个 Te ...

  5. Unit Testing PowerShell Code with Pester

    Summary: Guest blogger, Dave Wyatt, discusses using Pester to analyze small pieces of Windows PowerS ...

  6. Add/Remove listview web part in publish site via powershell

    1. Here is the code: Add WebPart in Publish Site Example : AddWebPartPublish http://localhost  " ...

  7. PowerShell 获取Site Collection下被签出的文件

    由于权限的设置,当文件被签出时导致别人不可见了,这对校验文件个数的人来说着实是件烦恼的事.幸好利用PowerShell,可以获取Site Collection下被签出的文件. Resolution A ...

  8. PowerShell 批量签入SharePoint Document Library中的文件

    由于某个文档库设置了编辑前签出功能,导致批量导入文件时这些文件默认的状态都被签出了.如果手动签入则费时费力,故利用PowerShell来实现批量签入Document Library中的文件. Reso ...

  9. SharePoint自动化部署,利用PowerShell 导入用户至AD——PART II

    这是对上一篇文章<SharePoint自动化部署,利用PowerShell 导出/导入AD中的用户>进行补充.开发时,为了测试和演示,我们往往需要经常性的把用户添加到AD中.数据量小的时候 ...

随机推荐

  1. android-退出动画无效

    在调用 overridePendingTransition(R.anim.anim_scale_in, R.anim.anim_scale_out); 方法设置某个Activity进入和退出动画的时候 ...

  2. HTML5之canvas元素

    定义和用法 fillStyle 属性设置或返回用于填充绘画的颜色.渐变或模式. 默认值: #000000 JavaScript 语法: context.fillStyle=color|gradient ...

  3. linx 设备名字来由 sd sr sg st

    转载保留:http://blog.csdn.net/luoweifeng1989/archive/2011/05/17/6426193.aspx 一直不知道 sda sdb sr0 这些名字的前两两个 ...

  4. JavaScript绘图类 (DIV绘图)

    主要的图形算法抄自一个叫w_jsGraphics.js的类库,第一次看到那个库的时候,感觉那是十分神奇的存在.不过估计现在那个库早就已经找不到了. 这是很早之前的一个DIV绘图类,那时候VML+SVG ...

  5. 在32位Centos6.4上安装GraphicsMagick

    安装时,make总是有如下错误,最后几行 /bin/sh ./libtool --tag=CC --mode=link gcc -std=gnu99 -g -O2 -Wall -pthread -ld ...

  6. 封装常用的selenium方法

    package com.yk.userlive.base; import java.net.MalformedURLException;import java.net.URL;import java. ...

  7. 什么是 Web?

    Web这个词刚开始显得有些泛泛,似乎“冲浪”.“网上存在”以及“主页”等等都和它拉上了一些关系. 甚至还有一种“Internet 综合症”的说法,对许多人狂热的上网行为提出了质疑.我们在这里有必要作一 ...

  8. 模式识别之贝叶斯---朴素贝叶斯(naive bayes)算法及实现

    处女文献给我最喜欢的算法了 ⊙▽⊙ ---------------------------------------------------我是机智的分割线----------------------- ...

  9. (转)java synchronised关键字

    转自:http://www.cnblogs.com/mengdd/archive/2013/02/16/2913806.html Java 多线程(六) synchronized关键字详解 Java ...

  10. 【统计分析】ROC曲线

    http://baike.baidu.com/link?url=O8nVf39qW4UpYAegk9cJfYARCFDg8YHQ6p5wFnWxYvo151doXo-WvG5Rfz0j4R-r 受试者 ...