首先创建具有如下结构的 CSV (users.csv):
Name,Sip
login1,login1@gmail.com
运行以下语句:
Import-Csv C:\PATH_TO_CSV\users.csv | foreach{cp C:\YOUR_PATH\YOUR_FILE ("C:\Users\"+$_.Name+"\AppData\Local\Microsoft\Communicator\"+$_.Sip)}\
更新当前用户运行的脚本:
$userName = [Environment]::UserName;
$domain = [Environment]::UserDomainName;
# Look for a user
$Rech = new-object System.DirectoryServices.DirectorySearcher
$rc = $Rech.filter = "((sAMAccountName=$userName))"
$rc = $Rech.SearchScope = "subtree"
$rc = $Rech.PropertiesToLoad.Add("mail");
$rc = $Rech.PropertiesToLoad.Add("msRTCSIP-PrimaryUserAddress");
$theUser = $Rech.FindOne()
Write-host "Username is" $userName
Write-host "Domain is" $domain
if ($theUser -ne $null)
{
Write-Host "Mail is" $theUser.Properties["mail"]
Write-Host "SIP is" $theUser.Properties["msRTCSIP-PrimaryUserAddress"]
}