PS Remoting到AD,Get-ADUser和具有本地variables的脚本块
我正在尝试编写一个PS脚本来pipe理AD对象,方法是连接到DC并使用Get-ADUser(以及其他某些其他cmdlet)检索信息。 我使用以下PS代码连接到DC: $global:MyDC = ($env:LOGONSERVER -replace "\\", "") + ".domain.com" $ADsession = New-PSSession -computerName $global:MyDC Invoke-Command -Session $ADsession -Command {Import-Module -Name ActiveDirectory} Import-PSSession -session $ADsession -module ActiveDirectory -Prefix RM 像这样的工程(所以我的PS Remoting似乎是确定的): $strUsersOU = "CN=UserOU,DC=domain,DC=com" $strResourcesOU = "OU=Resources," + $strUsersOU $strSharedOU = "OU=Shared," + $strUsersOU [array]$arrADusers = @(Get-RMADUser -Filter * -SearchBase $strUsersOU -Properties DisplayName, AccountExpirationDate, lockedout, […]