I have this code and get error
Invoke-Command -ComputerName (Get-Content .\DCs.txt) -scriptBlock { Get-ItemProperty HKLM:\System\CurrentControlSet\Control\SecurityProviders\Schannel\ -Name "CertificateMappingMethods" }
Invoke-Command : One or more computer names are not valid.
Not a foreach this time
Chances are you have an empty line or some random space(s.) I always prefer to treat it as CSV as Import-CSV
will clean up extra white space. Even if there is no header, just provide one
$dclist = Import-Csv .\DCs.txt -Header name
Invoke-Command -ComputerName $dclist.name -scriptBlock {
Get-ItemProperty HKLM:\System\CurrentControlSet\Control\SecurityProviders\Schannel\ -Name "CertificateMappingMethods"
}
Hey Doug, yes that was it. Too much white space, thank you
If I want to use set -itemproperty then (where the Key doesn’t yet exist), would this work?
$dclist = Import-Csv .\DCs.txt -Header name
Invoke-Command -ComputerName $DCs {
Set-ItemProperty HKLM:\System\CurrentControlSet\Control\SecurityProviders\Schannel\ -Name "CertificateMappingMethods" -Value '31'}
Olaf
August 16, 2022, 6:42am
4
jeff-taylor:
would this work?
Test it on a test pc. That will probably be faster than waiting for answer of someone who tested it for you.
it did! thanks Olaf…ran it straight-up without the invoke-command, locally