Note that there are some explanatory texts on larger screens.

plurals
  1. POPOWERSHELL info about counters and this statements
    text
    copied!<p>I found this code on a site :<a href="http://bsonposh.com/archives/288" rel="nofollow noreferrer">More userAccountControl Flag Fun (Convert-ToUACFlag.ps1) - http://bsonposh.com/archives/288</a>, for users in active directory. And I thought I understood it a bit, so I created a function for the other way around based on this article but it seems to work as a counter | (pipe) -> ? (if) The % is not (very) clear, what it does (I don't think it is the modulus operator, otherwise I misunderstand the piping)</p> <p>%= Assignment by modulus operator</p> <pre><code>echo( 1..($flags.length) | ? {$value -band [math]::Pow(2,$_)} | %{ $flags[$_] }); </code></pre> <p>and this is the original function, which works fine</p> <pre><code>function checkUserControl { param ([int]$value) $flags = @("","ACCOUNTDISABLE","", "HOMEDIR_REQUIRED", "LOCKOUT", "PASSWD_NOTREQD","PASSWD_CANT_CHANGE", "ENCRYPTED_TEXT_PWD_ALLOWED", "TEMP_DUPLICATE_ACCOUNT", "NORMAL_ACCOUNT", "","INTERDOMAIN_TRUST_ACCOUNT", "WORKSTATION_TRUST_ACCOUNT", "SERVER_TRUST_ACCOUNT", "", "", "DONT_EXPIRE_PASSWORD", "MNS_LOGON_ACCOUNT", "SMARTCARD_REQUIRED", "TRUSTED_FOR_DELEGATION", "NOT_DELEGATED","USE_DES_KEY_ONLY", "DONT_REQ_PREAUTH", "PASSWORD_EXPIRED", "TRUSTED_TO_AUTH_FOR_DELEGATION") echo( 1..($flags.length) | ? {$value -band [math]::Pow(2,$_)} | %{ $flags[$_] }); } </code></pre> <p>so my own try (several tries)</p> <pre><code>function checkUserControl2 { param ([string]$value) $flags = @("","ACCOUNTDISABLE","", "HOMEDIR_REQUIRED", "LOCKOUT", "PASSWD_NOTREQD","PASSWD_CANT_CHANGE", "ENCRYPTED_TEXT_PWD_ALLOWED", "TEMP_DUPLICATE_ACCOUNT", "NORMAL_ACCOUNT", "","INTERDOMAIN_TRUST_ACCOUNT", "WORKSTATION_TRUST_ACCOUNT", "SERVER_TRUST_ACCOUNT", "", "", "DONT_EXPIRE_PASSWORD", "MNS_LOGON_ACCOUNT", "SMARTCARD_REQUIRED", "TRUSTED_FOR_DELEGATION", "NOT_DELEGATED","USE_DES_KEY_ONLY", "DONT_REQ_PREAUTH", "PASSWORD_EXPIRED", "TRUSTED_TO_AUTH_FOR_DELEGATION") #echo( 1..($flags.length) | ? {$value -eq $flags[$_] } )} | %{$_}); #echo( 1..($flags.length) | ? {$value -match $flags[$_] } )} | %{$_}); #echo( 1..($flags.length) | ? {$value -ieq $flags[$_] } )} | %{$_}); #echo( 1..($flags.length) | ? {$value -imatch $flags[$_] } )} | %{ $_ }); #echo( 1..($flags.length) | ? {$value -ieq $flags[$_] } )} | {$_}); echo( 1..($flags.length) | ? {$value -imatch $flags[$_] } )} | { $_ }); } echo "DONT_EXPIRE_PASSWORD"; checkUserControl2("DONT_EXPIRE_PASSWORD"); </code></pre> <p>the error I get <code>an empty pipe is not allowed</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload