首页 > 代码库 > Powershell Get-registerkey(susid)
Powershell Get-registerkey(susid)
$servers=get-content D:\serverregister.txtGet-registerkey -ComputerName $servers | select computer,susid| Export-Csv d:\registerkey1.csv -NoTypeInformation
Function Get-registerkey
引用前一篇文章中的代码的一部分做修改,从注册表中查询server的susid
Function Get-registerkey{<# #>[CmdletBinding()]param( [Parameter(Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [Alias("CN","Computer")] [String[]]$ComputerName="$env:COMPUTERNAME", [String]$ErrorLog ) Begin { }## End Begin Script BlockProcess { Foreach ($Computer in $ComputerName) { Try { ## Querying WMI for build version $WMI_OS = Get-WmiObject -Class Win32_OperatingSystem -Property BuildNumber, CSName -ComputerName $Computer -ErrorAction Stop ## Making registry connection to the local/remote computer $HKLM = [UInt32] "0x80000002" $WMI_Reg = [WMIClass] "\\$Computer\root\default:StdRegProv" ## Query SusClientId from the registry $RegWUAUsusid = $WMI_Reg.GetStringValue($HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\","SusClientId") $WUAUsusid= $RegWUAUsusid.sValue ## Creating Custom PSObject and Select-Object Splat $SelectSplat = @{ Property=( ‘Computer‘, ‘susid‘ )} New-Object -TypeName PSObject -Property @{ Computer=$WMI_OS.CSName susid=$WUAUsusid } | Select-Object @SelectSplat } Catch { Write-Warning "$Computer`: $_" ## If $ErrorLog, log the file to a user specified location/path If ($ErrorLog) { Out-File -InputObject "$Computer`,$_" -FilePath $ErrorLog -Append } } }## End Foreach ($Computer in $ComputerName) }## End Process End { }## End End }## End Function Get-registerkey
Powershell Get-registerkey(susid)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。