Jun 23 2020 05:48 AM
Jun 23 2020 05:48 AM
We are confronted with the task to change AD information from a Linux server. As the ability to load the AD module is not implemented in PS Core 7 on Linux machines (as mentioned here) we created a remote session to one of our terminal servers and executed the script on that machine.
To do so, we created a credential object for that user on the terminal server and loaded it in the script before executing the AD commands. This works perfectly, as long as the user in whose context we are running the script is logged into the terminal server. It stops working with a CryptographicException as soon as this user is logged out.
Do you know of any way to correctly access stored credential information for remoting when coming from a linux powershell? We've tried to open the session using Credssp authentication, but this is not working either. We know that we can pass the password to the remote session and create a new credential object, but we would rather not go that way.
All help is appreciated.
Jun 30 2020 11:45 PM - edited Jun 30 2020 11:45 PM
What we ultimately want to do is to add a user to an AD-Group triggered from a Linux-Host. The Linux-Host has installed the latest Powershell. As far as we learned, the AD module is not available to be loaded on the Powershell in the Linux host.
So, we relied on 'new-pssession' and 'invoke-command' to a windows server. The invoke command calls a script on the windows server, supplying the correct arguments. The script itself does all the necessary actions to add the user to the desired AD group. It does this by first loading a stored credentials file and then calling the method with that credentials:
$cred=import-clixml -path $credentialFileName ... Add-ADGroupMember -credential $cred -server $aServer -identity $aGroup -members $aUser
This works perfectly, as long as the user that we are using to run the script (the same user we use to open the new-pssession from the linux host) is logged in locally as the Windows server. If that user logs out, the credentials file cannot be imported anymore.
As an alternative, we tried to pass the credentials opening the session with -Authentication 'Credssp' instead of 'Negotiate', but that fails coming from a Linux host.