Powershell:Get-ExchangeUpdateRollups

代码参考至:http://www.bhargavs.com/。

  1 #############################################################################
  2 # Get-ExchangeUpdateRollups.ps1
  3 # Gets the Exchange Server 2007, Exchange 2010 and Exchange 2013 Update Rollups
  4 # installed writes output to CSV file in same folder where script is called from
  5 #
  6 # Exchange 2013 CU Build Numbers - http://social.technet.microsoft.com/wiki/contents/articles/15776.exchange-server-2013-and-cumulative-updates-cus-build-numbers.aspx
  7 # Exchange Server Update Rollups and Build Numbers - http://social.technet.microsoft.com/wiki/contents/articles/240.exchange-server-and-update-rollups-build-numbers.aspx
  8 #
  9 # This script won‘t report RUs for Exchange Server 2013 since it uses Cummulative Updates (CU).
 10 # More details on Exchange Team Blog: Servicing Exchange 2013
 11 # http://blogs.technet.com/b/exchange/archive/2013/02/08/servicing-exchange-2013.aspx
 12 #
 13 # Created by
 14 # Bhargav Shukla
 15 # http://www.bhargavs.com
 16 #
 17 # DISCLAIMER
 18 # ==========
 19 # THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
 20 # RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
 21 #############################################################################
 22
 23 # Store header in variable
 24 $headerLine =
 25 @"
 26 Exchange 2013 CU Build Numbers - http://social.technet.microsoft.com/wiki/contents/articles/15776.exchange-server-2013-and-cumulative-updates-cus-build-numbers.aspx
 27 Exchange Server Update Rollups and Build Numbers - http://social.technet.microsoft.com/wiki/contents/articles/240.exchange-server-and-update-rollups-build-numbers.aspx
 28
 29 Server Name,Rollup Update Description,Installed Date,ExSetup File Version
 30 "@
 31
 32 # Write header to file
 33 $headerLine | Out-File .\results.csv -Encoding ASCII -Append
 34
 35 function getRU([string]$Server)
 36 {
 37 # Set server to connect to
 38     $Server = $Server.ToUpper()
 39
 40 # Check if server is running Exchange 2007, Exchange 2010 or Exchange 2013
 41
 42     $ExchVer = (Get-ExchangeServer $Server | ForEach {$_.AdminDisplayVersion})
 43
 44 # Set appropriate base path to read Registry
 45 # Exit function if server is not running Exchange 2007, Exchange 2010 or Exchange 2013
 46     if ($ExchVer -match "Version 15")
 47     {
 48         $REG_KEY = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\AE1D439464EB1B8488741FFA028E291C\\Patches"
 49         $Reg_ExSetup = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\Setup"
 50     }
 51     elseif ($ExchVer -match "Version 14")
 52     {
 53         $REG_KEY = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\AE1D439464EB1B8488741FFA028E291C\\Patches"
 54         $Reg_ExSetup = "SOFTWARE\\Microsoft\\ExchangeServer\\v14\\Setup"
 55     }
 56     elseif    ($ExchVer -match "Version 8")
 57     {
 58         $REG_KEY = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\461C2B4266EDEF444B864AD6D9E5B613\\Patches"
 59         $Reg_ExSetup = "SOFTWARE\\Microsoft\\Exchange\\Setup"
 60     }
 61     else
 62     {
 63         return
 64     }
 65
 66 # Read Rollup Update information from servers
 67 # Set Registry constants
 68     $VALUE1 = "DisplayName"
 69     $VALUE2 = "Installed"
 70     $VALUE3 = "MsiInstallPath"
 71
 72 # Open remote registry
 73     $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine‘, $Server)
 74
 75 # Set regKey for MsiInstallPath
 76     $regKey= $reg.OpenSubKey($REG_ExSetup)
 77
 78 # Get Install Path from Registry and replace : with $
 79     $installPath = ($regkey.getvalue($VALUE3) | foreach {$_ -replace (":","`$")})
 80
 81 # Set ExSetup.exe path
 82     $binFile = "Bin\ExSetup.exe"
 83
 84 # Get ExSetup.exe file version
 85     $exSetupVer = ((Get-Command "\\$Server\$installPath$binFile").FileVersionInfo | ForEach {$_.FileVersion})
 86
 87 # Create an array of patch subkeys
 88     $regKey= $reg.OpenSubKey($REG_KEY).GetSubKeyNames() | ForEach {"$Reg_Key\\$_"}
 89
 90 # Walk through patch subkeys and store Rollup Update Description and Installed Date in array variables
 91     $dispName = [array] ($regkey | %{$reg.OpenSubKey($_).getvalue($VALUE1)})
 92     $instDate = [array] ($regkey | %{$reg.OpenSubKey($_).getvalue($VALUE2)})
 93
 94 # Loop Through array variables and output to a file
 95     $countmembers = 0
 96
 97     if ($regkey -ne $null)
 98     {
 99         while ($countmembers -lt $dispName.Count)
100         {
101         $server+","+$dispName[$countmembers]+","+$instDate[$countmembers].substring(0,4)+"/"+$instDate[$countmembers].substring(4,2)+"/"+$instDate[$countmembers].substring(6,2)+","+$exsetupver | Out-File .\results.csv -Encoding ASCII -Append
102         $countmembers++
103         }
104     }
105     else
106     {
107         $server+",No Rollup Updates are installed,,"+$exsetupver | Out-File .\results.csv -Encoding ASCII -Append
108     }
109 }
110
111 # Get Exchange 2007/2010 servers and write Rollup Updates to results file
112 $Servers = (Get-ExchangeServer -Identity WENDY* | Where-Object {($_.AdminDisplayVersion -match "Version 8" -OR $_.AdminDisplayVersion -match "Version 14" -OR $_.AdminDisplayVersion -match "Version 15") -AND $_.ServerRole -ne "ProvisionedServer" -and $_.ServerRole -ne "Edge"} | ForEach {$_.Name})
113 $Servers | ForEach {getRU $_}
114 Write-Output "Results are stored in $(Get-Location)\results.csv"

时间: 2024-11-13 08:22:21

Powershell:Get-ExchangeUpdateRollups的相关文章

PowerShell:因为在此系统上禁止运行脚本

在安装chocolatey(官网)的时候,不能运行chocolateyInstall.pal脚本文件. 查阅资料后,得出如下解决办法: 首次在计算机上启动 Windows PowerShell 时,现用执行策略很可能是 Restricted(默认设置). Restricted 执行策略不允许任何脚本运行.     AllSigned 和 RemoteSigned 执行策略可防止 Windows PowerShell 运行没有数字签名的脚本. 本主题说明如何运行所选未签名脚本(即使在执行策略为 R

PowerShell:30行代码轻松实现SQL Server数据库容量监控

本文介绍如何用PowerShell脚本实现SQL Server数据库容量监控 闲话就不多说,直入主题 一.建表 为每台服务器创建一个表,用于记录服务器各个数据库的容量,以服务器名作为表名. CREATE TABLE table_name( [LOG_DATE] [varchar](20) NULL, [DB_NAME] [varchar](50) NULL, [TOTAL_SIZE_MB] [numeric](15, 2) NULL, [USE_SIZE_MB] [numeric](15, 2)

PowerShell:在Windows 10中为Wi-Fi网络生成QR代码

您可以使用PowerShell生成QR代码以与您的朋友或同事共享.使用QRCodeGenerator PowerShell模块生成QR码图像的示例,您的同事或来宾可使用该QR码图像连接到Wi-Fi网络(因为您不想将密码指定给每个朋友)). QRCodeGenerator模块可用于为以下对象类型生成带有QR码的PNG文件: vCard联系人卡(名片) 地理数据 Wi-Fi连接设置 您可以手动下载QRCodeGenerator模块(https://www.powershellgallery.com/

微软宣布开源PowerShell:Linux和MacOS版到来

http://www.ithome.com/html/soft/250719.htm https://github.com/PowerShell

CentOS 7 上面安装PowerShell

看了文章 爱上PowerShell , 就想在CentOS 7上面试试PowerShell , 本文记录了在CentOS 7.2上安装Powershell 的过程. 首先我们要从github上下载最新的PowerShell 的rpm 包powershell-6.0.0_alpha.14-1.el7.centos.x86_64.rpm,安装方法的文档 https://github.com/PowerShell/PowerShell/blob/master/docs/installation/lin

CMD命令:开始->运行->键入cmd或command(在命令行里可以看到系统版本、文件系统版本)

CMD命令 CMD命令:开始->运行->键入cmd或command(在命令行里可以看到系统版本.文件系统版本) appwiz.cpl:程序和功能 calc:启动计算器 certmgr.msc:证书管理实用程序 charmap:启动字符映射表 chkdsk.exe:Chkdsk磁盘检查(管理员身份运行命令提示符) cleanmgr: 打开磁盘清理工具 cliconfg:SQL SERVER 客户端网络实用工具 cmstp:连接管理器配置文件安装程序 cmd.exe:CMD命令提示符 自动关机命令

浅尝Windows Server 2016——Container 容器:部署

容器上手其实挺快的,特别是在熟悉的Windows环境下.起步无非这么几件事: 1.安装Container Feature,容器功能角色 可以使用UI,当然也可以用PowerShell: Install-WindowsFeature containers Restart-Computer -Force 由于容器本身可以跑在物理机或者虚拟机中,可以顺便把Hyper-V也装了. 2.安装Docker 可以很炫的用PowerShell来拉取Docker引擎: Invoke-WebRequest "htt

显示、隐藏 PowerShell

以下是一个快速实现该需求的 module.只要将以下代码复制粘贴到 Documents\WindowsPowerShell\Packages\PowerShell\PowerShell.psm1 即可. $script:showWindowAsync = Add-Type –memberDefinition @" [DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, i

PowerShell: 问题,此系统上禁止运行脚本解决方法

刚学Django,在PowerShell上建立一个虚拟环境,准备激活,问题来了:    激活的时候报错了,有点儿懵,之前在命令行没问题啊,我又去命令行试了下,果然可以: 感受到了暴击,赶紧上网求助大神,一番搜索,发现了是PowerShell的设置问题,脚本的默认执行策略 Restricted,禁止运行任何脚本和配置文件, 需要更改一下设置,怎么修改,已管理员身份打开PowerShell: 使用get-executionpolicy 查看脚本执行策略,使用set-executionpolicy R