I was going to automate AD user creation with powershell on server 2008 R2 but have hit a problem.
When I try to run the addUser.p1 script from the powershell command line or from a CMD shell using powershell.exe addUser.p1 with or without the full or relative path (from within the directory where the script resides) notepad.exe opens.
I have only 2 lines in the script as I wanted to see if it was the script causing problems. It takes the username as an arg and creates a profile directory based on the username.
The script is as follows:
$serverName = "SERVER03"
If I run the test command '[IO.Directory]::CreateDirectory("\\SERVER03\profiles\testUser"' directly in powershell then it does indeed create a directory.
I have already run 'Set-ExecutionPolicy RemoteSigned' and am running the script on the server itself.