これまでに定義した-Computername $Server
を使用してPSSessionを入力しようとしていますが、これが機能しないようです。ComputerNameの変数付きPSSessionを入力してください
私は、変数のまわりに一重引用符、二重引用符、および全く引用符を使用しませんでした。私は間違って何をしていますか?私たちは、リモートコンピュータとの対話型セッションを作成するためのPSSessionを入力して使用
$Servers = Import-Csv "C:\Users\username\Desktop\DNS.csv"
$secpass = ConvertTo-SecureString 'mypassword' -AsPlainText -Force
$myCred = New-Object System.Management.Automation.PSCredential("username", $secpass)
foreach ($Object in $Servers) {
$Server = $Object.Name
Enter-PSSession -ComputerName "$Server" -Credential $myCred
sl HKLM:\SYSTEM\CurrentControlSet\Services\NetBT\Parameters
Invoke-Command -ScriptBlock {Get-Item -Path HKLM:\SYSTEM\CurrentControlSet\Services\NetBT\Parameters}
Exit-PSSession
}
ない引用符または二重引用符は問題ないはずです、何の置換は行われません一重引用符を使用するので、ここでは動作しません。詳細については、[about_quoting_rules](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_quoting_rules)を参照してください。接続しようとしているサーバーで[リモーティングを有効にする](https://technet.microsoft.com/en-us/library/ff700227.aspx)していますか? –
はい、すべてのサーバーでリモート処理が有効になっています –