#param( [string] $importfile = $(Read-Host -prompt "Please enter a file name"))
#$importedComputers = Import-CSV $importfile
$importedComputers = Import-CSV .\ComputerNames.csv
foreach ($importedComputer in $importedComputers)
{
Enter-PSSession -ComputerName $importedComputer.nComputerName
$pfxpath = 'C:\Cert\i-x-Cloud.com.pfx'
$password01 = '1'
Add-Type -AssemblyName System.Security
$cred01 = ConvertTo-SecureString "1" -AsPlainText -Force
$Username = 'i-x-Cloud\administrator'
$Password = 'Aa123456'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Invoke-Command -ComputerName $importedComputer.nComputerName -ScriptBlock { Import-PfxCertificate -Exportable -FilePath 'C:\Cert\i-x-Cloud.com.pfx' Cert:\LocalMachine\my -Password (ConvertTo-SecureString -String '1' -AsPlainText -Force)} -credential $Cred
}
121-OWAS01.i-x-Cloud.com
122-OWAS02.i-x-Cloud.com
131-mail01.i-x-Cloud.com
132-mail02.i-x-Cloud.com
151-SFBFE01.i-x-Cloud.com
152-SFBFE02.i-x-Cloud.com
153-SFBFE03.i-x-Cloud.com
161-SFBPC01.i-x-Cloud.com
在以上服务器中的MMC中删除证书。
批量导入证书。
171-SFBEdge01.i-x-Cloud.com //本地导入
254-TMG01.i-x-Cloud.com //本地导入
Import-PfxCertificate -FilePath 'C:\Cert\i-x-Cloud.com.pfx' Cert:\LocalMachine\my -Password (ConvertTo-SecureString -String '1' -AsPlainText -Force)