I am trying to make a script that runs some cmd command to set SPN: something in effect of for each item in my list run setspn -s (name of the spn) domain\service account but I have a hard time running command line as well as i need to be able to change (name of SPN as i go though the list)
$List = Get-Content C:\Users\MyComputer\Desktop\Lists.txt
foreach($PN in $List){
$Semper_fi = @'
cmd.exe /C setspn –S "some SPN name\corp.com:1000" corporatedomain\ServiceAccount1
'@
Invoke-Expression -Command:$Semper_fi
}
-S is suppose to look in AD and if the name doesn't exist adds or otherwise moves to next item and so on. but it gives me an error: + CategoryInfo : NotSpecified: (Unknown paramet...eck your usage.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
so it would like this for every name in the list: (check to see if not in ad add this) (this SPN) setspn -s serverSQL1/pop1.company.com:2500
(under this service account) Domain\Service100
and keep going until done.