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中.数据量小的时候 ...
随机推荐
- Freeswitch中文用户手册(第四章 SIP)----2
通过 B2BUA 呼叫 在真实世界中,bob 和 alice 肯定要经常改变位置,那么它们的 SIP 地址也会相应改变,并且,如果他们之中有一个或两个处于 NAT 的网络中时,直接通信就更困难了.所以 ...
- DirectShow中写push模式的source filter流程 + 源码(内附具体凝视)
尽管网上已有非常多关于DirectShow写source filter的资料.只是非常多刚開始学的朋友总说讲的不是非常清楚(可能当中作者省略了很多他觉得简 单的过程).读者总希望看到象第一步怎么做,第 ...
- Oracle 版本号说明
Oracle 的版本非常多,先看11g的一个版本说明: 注意: 在oracle 9.2 版本号之后, oracle 的maintenance release number 是在第二数字位更改. 而在之 ...
- python学习之strip()
定义: Python strip() 方法用于移除字符串头尾指定的字符(默认为空格). 语法: str.strip([chars]); 返回值: 返回移除字符串头尾指定的字符生成的新字符串. 例子: ...
- [JNA系列]Java调用Delphi编写的Dll之Delphi与JAVA基本数据类型对比
Delphi与JAVA基本数据类型对比 类型 Delphi关键字 JAVA关键字 字节 备注 范围 整型 Shortint byte 1 有符号8位 -128..127 Byte 1 无符号8位 0 ...
- struts-tiles学习笔记
网上搜了一些,稀里糊涂的,要么是代码不全,要么是版本不对,还是去struts官网大概学习了一下 http://struts.apache.org/development/1.x/struts-tile ...
- HTML页面中直接加载其他JSP页面
1.在经典的框架中填充页面时 要填充2处的页面,2处为内容页面,是另外的一个JSP页面 2.左侧页面代码 <%@ page language="java" import=&q ...
- TDS协议解析
文章来自:http://freetds.cvs.sourceforge.net/*checkout*/freetds/freetds/doc/tds.html 该网站是免费的专门介绍TDS协议的,网址 ...
- ZoneDateTime 转换Date
final ZonedDateTime now = ZonedDateTime.now(); //当前时间final ZonedDateTime todayZero = now.truncatedTo ...
- 使用 Google Guava 美化你的 Java 代码:1~4(转)
参考:https://my.oschina.net/leejun2005/blog/172328 记录不做具体转载了