Script works in PowerShell ISE but not in regular PowerShell window


hello all!

i've got ps conundrum ponder.  have following script lines:

write-host"check password complexity requirements:"-foregroundcolorblack-backgroundcolorwhite

write-host""

import-moduleactivedirectory

$passwordpolicy=get-adobject$rootdse.defaultnamingcontext -propertypwdproperties

$passwordpolicy|select@{n="policytype";e={"password"}},`

distinguishedname,`

@{n

="password complexity requirements";e={switch($_.pwdproperties) {

0{"passwords can simple , administrator account cannot locked out"

1{"passwords must complex , administrator account cannot locked out"

8{"passwords can simple, , administrator account can locked out"

9{"passwords must complex, , administrator account can locked out"

default{$_.pwdproperties}}}} |ft*-auto

when run code in ise, works great.  returns value setting "1" gpo set to.

but, when run same code in elevated powershell prompt, following error:

any appreciated.

you can't use variable if haven't created it.

don't retire technet! - (don't give yet - 13,085+ strong , growing)



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Generating Event ID 91, 44 with CA (In Event Viewer with source as Certsvc)

Group policy default policy cannot be edited because network name not found

Problem when changing update source