Running powershell script from CMD does not load module


so have easy powershell script contains following:

import-module activedirectory

get-aduser -filter *

remove-module activedirectory

if run powershell runs ok, when try call cmd nothing happens, opens powershell , thats it. using following command run it:

powershell.exe -file "d:\test.ps1"

i noticed following thing, 2 powershell.exe processes run after execute this. if exit cmd 1 powershell start seeing lists ps query should returning. there way working since trying run ps script scheduled job. crucial part here import module when run on cmd not happening reason.

it's powershell 2.0 running on windows 2008r2. tried script on win 2012r2, works fine cmd... looks ps 2.0 limitation?

what happens if do

start powershell.exe -file d:\test.ps1


if find post has answered question, please mark answer. if find post helpful in anyway, please click vote helpful.

don't retire technet



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group