Powershell Function Get-TimeZone
代码原文地址: 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的更多相关文章
- Powershell Function Get-PendingReboot
获取系统中Restart Pending的计算机 $servers=get-content D:\serverlist.txt Get-PendingReboot -ComputerName $ser ...
- 【Azure 应用服务】Azure Function 启用 Managed Identity后, Powershell Funciton出现 ERROR: ManagedIdentityCredential authentication failed
问题描述 编写Powershell Function,登录到China Azure并获取Azure AD User信息,但是发现遇见了 [Error] ERROR: ManagedIdentityCr ...
- 如何通过PowerShell在Visual Studio的Post-build中预热SharePoint站点
问题现象 Visual Studio在开发SharePoint的时候,发布部署包后,首次打开及调试站点页面的时候会非常的慢 解决方案 使用PowerShell脚本,加载SharePoint插件后遍历所 ...
- SharePoint自动化系列——Manage "Site Subscriptions" using PowerShell
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 你可以将普通的sites加入到你的site subscriptions中,前提是你需要有一个 Te ...
- Unit Testing PowerShell Code with Pester
Summary: Guest blogger, Dave Wyatt, discusses using Pester to analyze small pieces of Windows PowerS ...
- Add/Remove listview web part in publish site via powershell
1. Here is the code: Add WebPart in Publish Site Example : AddWebPartPublish http://localhost " ...
- PowerShell 获取Site Collection下被签出的文件
由于权限的设置,当文件被签出时导致别人不可见了,这对校验文件个数的人来说着实是件烦恼的事.幸好利用PowerShell,可以获取Site Collection下被签出的文件. Resolution A ...
- PowerShell 批量签入SharePoint Document Library中的文件
由于某个文档库设置了编辑前签出功能,导致批量导入文件时这些文件默认的状态都被签出了.如果手动签入则费时费力,故利用PowerShell来实现批量签入Document Library中的文件. Reso ...
- SharePoint自动化部署,利用PowerShell 导入用户至AD——PART II
这是对上一篇文章<SharePoint自动化部署,利用PowerShell 导出/导入AD中的用户>进行补充.开发时,为了测试和演示,我们往往需要经常性的把用户添加到AD中.数据量小的时候 ...
随机推荐
- Windows Azure Platform 性能监视器(转载)
Windows操作系统提供了查看性能监视器的功能,用于监视CPU使用率.内存使用率,硬盘读写速度,网络速度等.您可以在开始-->运行-->输入Perfmon,就可以打开性能监视器. 我们知 ...
- Wpf ScrollBar自定义样式
Wpf的ScrollBar可以分为六个区域:A.背景.B.向上按钮.C.向下的按钮.D.Track里面向上的按钮.E.Track里面向下的按钮.F.Track的Thumb 详情见下图 下面通过一个例子 ...
- C++刷题——2830: 递归求1*1+2*2+3*3+……+n*n
Description 定义一个递归函数sum int sum(int n); //函数声明,返回12+22+32+--+n2的和 注意:sum为递归函数 Input 正整数n的值 Output 12 ...
- 1.文件I/O
一. open()&close() #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h& ...
- makefile之shell函数
shell函数不同于除"wildcard"函数之外的其它函数.make可以使用它来和外部通信. 函数功能:函数"shell"所实现的功能和shell中的引用(` ...
- PHP7:10件事情你需要知道的
你是一个Web开发人员或网站所有者?做你的网站上的PHP-enabledCMS如WordPress,Drupal的是,Joomla或Magento的运行?然后,我对你的好消息:新的PHP 7的功能完整 ...
- PHP学习笔记(15)PDO数据库操作+AJAX无刷新技术删除用户
pdo.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
- HTML5七巧板canvas绘图
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- 2种实现CXF方法例子
转载自:http://www.blogjava.net/sai5201314vicky/articles/353078.html 大家好,今天我要介绍的现实webservice的一种技术——CXF 由 ...
- Java异常框架设计
什么是异常? 异常(exception)应该是异常事件(exceptional event)的缩写.异常定义:异常是一个在程序执行期间发生的事件,它中断正在执行的程序的正常的指令流.当在一个方法中发生 ...