I am preparing a script. What I want to do is to get the user SID from Active Directory and use it in another command.
I tried to do this command but couldn't run it
$username = Read-Host -Prompt 'Erdem.OV'
$SID = Get-ADUser -Identity $username | select-object SID
$PSExec = "C:\Windows\System32\PsExec.exe"
$hostname = Read-Host -Prompt 'hostname'
$command = 'cmd /c "reg add "HKEY_USERS\"$SID"\SOFTWARE\Policies\Microsoft\Internet Explorer\Control Panel" /v ConnectionsTab /t REG_DWORD /d 0"'
Start-Process -Filepath "$PsExec" -ArgumentList "\\$hostname $command"
Thanks.