zoukankan      html  css  js  c++  java
  • Powershell Get-registerkey(susid)

    $servers=get-content D:serverregister.txt
    Get-registerkey -ComputerName $servers | select computer,susid| Export-Csv d:
    egisterkey1.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 Block
    Process {
      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
    ootdefault:StdRegProv"
                
                ## Query SusClientId from the registry
               $RegWUAUsusid = $WMI_Reg.GetStringValue($HKLM,"SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate","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
    View Code
  • 相关阅读:
    app ios info权限配置:
    ionic3 小记录
    mipush ionic3 线上push
    ionic3 生命周期 之 ionViewWillLeave 坑
    iphone X 底部留白 之 ionic3 项目
    微信小程序 修改手机状态栏颜色
    git 命令
    微信小程序 下拉加载
    js 判断浏览器型号
    关于 ionic3 tabs 导航ico 点击 页面返回顶部
  • 原文地址:https://www.cnblogs.com/thescentedpath/p/registerkey.html
Copyright © 2011-2022 走看看