0
功能獲取-loggedOnUser顯示了3個項目,並且代碼可以在這裏找到LoggedInUser拉動功能的值到變量
- 計算機名稱
- 登錄的用戶
- 希德用戶
我希望能夠取得LoggedOnUser函數的結果(只需要登錄的用戶)並將結果傳遞給下面稱爲用戶名的變量。
Import-Module ActiveDirectory
function Get-LoggedOnUser
$credential = Get-Credential
$computers = "MachineName"
foreach ($machine in $computers)
{
Get-LoggedOnUser -ComputerName $machine
$username = $_.LoggedOn
$sid = ((get-aduser $username).SID).Value
Invoke-Command -ComputerName $machine -Credential $credential -ScriptBlock { New-PSDrive -Name HKU -PSProvider Registry -Root Registry::HKEY_USERS; New-ItemProperty -Path "HKU:\$($args[0])\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -PropertyType String -Name AutoConfigURL -Value "http://proxy.domain.com/proxies/proxy.pac" -Force } -argumentlist $sid
}
感謝您的幫助! – NobleMan 2014-10-19 23:35:51