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

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS