Description: List of useful reminders for Windows PowerShell
Accelerators ASCII ColorIndex Escape characters LDAP Filter Operators Regex Special characters UserAccountControl |
Accelerators
1 2 3 4 |
[PSObject].Assembly.GetType('System.Management.Automation.TypeAccelerators')::Get.GetEnumerator() | Select-Object -Property @{Name='Accelerator'; Expression={$_.Key}},@{name='.NET Class'; Expression={$_.Value}} | Sort-Object -Property Accelerator | Format-Table -AutoSize |
Accelerator | .NET Class |
---|---|
[adsi] | System.DirectoryServices.DirectoryEntry |
[adsisearcher] | System.DirectoryServices.DirectorySearcher |
[Alias] | System.Management.Automation.AliasAttribute |
[AllowEmptyCollection] | System.Management.Automation.AllowEmptyCollectionAttribute |
[AllowEmptyString] | System.Management.Automation.AllowEmptyStringAttribute |
[AllowNull] | System.Management.Automation.AllowNullAttribute |
[array] | System.Array |
[bigint] | System.Numerics.BigInteger |
[bool] | System.Boolean |
[byte] | System.Byte |
[char] | System.Char |
[cimclass] | Microsoft.Management.Infrastructure.CimClass |
[cimconverter] | Microsoft.Management.Infrastructure.CimConverter |
[ciminstance] | Microsoft.Management.Infrastructure.CimInstance |
[cimtype] | Microsoft.Management.Infrastructure.CimType |
[CmdletBinding] | System.Management.Automation.CmdletBindingAttribute |
[cultureinfo] | System.Globalization.CultureInfo |
[datetime] | System.DateTime |
[decimal] | System.Decimal |
[double] | System.Double |
[float] | System.Single |
[guid] | System.Guid |
[hashtable] | System.Collections.Hashtable |
[initialsessionstate] | System.Management.Automation.Runspaces.InitialSessionState |
[int] | System.Int32 |
[int16] | System.Int16 |
[int32] | System.Int32 |
[int64] | System.Int64 |
[ipaddress] | System.Net.IPAddress |
[long] | System.Int64 |
[mailaddress] | System.Net.Mail.MailAddress |
[NullString] | System.Management.Automation.Language.NullString |
[OutputType] | System.Management.Automation.OutputTypeAttribute |
[Parameter] | System.Management.Automation.ParameterAttribute |
[powershell] | System.Management.Automation.PowerShell |
[psaliasproperty] | System.Management.Automation.PSAliasProperty |
[pscredential] | System.Management.Automation.PSCredential |
[pscustomobject] | System.Management.Automation.PSObject |
[PSDefaultValue] | System.Management.Automation.PSDefaultValueAttribute |
[pslistmodifier] | System.Management.Automation.PSListModifier |
[psmoduleinfo] | System.Management.Automation.PSModuleInfo |
[psnoteproperty] | System.Management.Automation.PSNoteProperty |
[psobject] | System.Management.Automation.PSObject |
[psprimitivedictionary] | System.Management.Automation.PSPrimitiveDictionary |
[psscriptmethod] | System.Management.Automation.PSScriptMethod |
[psscriptproperty] | System.Management.Automation.PSScriptProperty |
[PSTypeNameAttribute] | System.Management.Automation.PSTypeNameAttribute |
[psvariable] | System.Management.Automation.PSVariable |
[psvariableproperty] | System.Management.Automation.PSVariableProperty |
[ref] | System.Management.Automation.PSReference |
[regex] | System.Text.RegularExpressions.Regex |
[runspace] | System.Management.Automation.Runspaces.Runspace |
[runspacefactory] | System.Management.Automation.Runspaces.RunspaceFactory |
[sbyte] | System.SByte |
[scriptblock] | System.Management.Automation.ScriptBlock |
[securestring] | System.Security.SecureString |
[single] | System.Single |
[string] | System.String |
[SupportsWildcards] | System.Management.Automation.SupportsWildcardsAttribute |
[switch] | System.Management.Automation.SwitchParameter |
[timespan] | System.TimeSpan |
[type] | System.Type |
[uint16] | System.UInt16 |
[uint32] | System.UInt32 |
[uint64] | System.UInt64 |
[uri] | System.Uri |
[ValidateCount] | System.Management.Automation.ValidateCountAttribute |
[ValidateLength] | System.Management.Automation.ValidateLengthAttribute |
[ValidateNotNull] | System.Management.Automation.ValidateNotNullAttribute |
[ValidateNotNullOrEmpty] | System.Management.Automation.ValidateNotNullOrEmptyAttribute |
[ValidatePattern] | System.Management.Automation.ValidatePatternAttribute |
[ValidateRange] | System.Management.Automation.ValidateRangeAttribute |
[ValidateScript] | System.Management.Automation.ValidateScriptAttribute |
[ValidateSet] | System.Management.Automation.ValidateSetAttribute |
[version] | System.Version |
[void] | System.Void |
[wmi] | System.Management.ManagementObject |
[wmiclass] | System.Management.ManagementClass |
[wmisearcher] | System.Management.ManagementObjectSearcher |
[xml] | System.Xml.XmlDocument |
ColorIndex
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# Create Excel COM Object $excel = New-Object -ComObject Excel.Application # Make the Excel windows visible $excel.Visible = $true # Add Workbook $workbook = $excel.Workbooks.Add() # Add Worksheet $sheet = $workbook.worksheets.item(1) $sheet.Name = 'Users' # Color Font $sheet.Cells.Item($row,$column).Font.ColorIndex = 3 # Background color $sheet.Cells.Item($row,$column).Interior.ColorIndex = 6 |
ColorIndex | Colour | HTML |
---|---|---|
1 | #000000 | |
2 | #FFFFFF | |
3 | #FF0000 | |
4 | #00FF00 | |
5 | #0000FF | |
6 | #FFFF00 | |
7 | #FF00FF | |
8 | #00FFFF | |
9 | #800000 | |
10 | #008000 | |
11 | #000080 | |
12 | #808000 | |
13 | #800080 | |
14 | #008080 | |
15 | #C0C0C0 | |
16 | #808080 | |
17 | #9999FF | |
18 | #993366 | |
19 | #FFFFCC | |
20 | #CCFFFF | |
21 | #660066 | |
22 | #FF8080 | |
23 | #0066CC | |
24 | #CCCCFF | |
25 | #000080 | |
26 | #FF00FF | |
27 | #FFFF00 | |
28 | #00FFFF | |
29 | #800080 | |
30 | #800000 | |
31 | #008080 | |
32 | #0000FF | |
33 | #00CCFF | |
34 | #CCFFFF | |
35 | #CCFFCC | |
36 | #FFFF99 | |
37 | #99CCFF | |
38 | #FF99CC | |
39 | #CC99FF | |
40 | #FFCC99 | |
41 | #3366FF | |
42 | #33CCCC | |
43 | #99CC00 | |
44 | #FFCC00 | |
45 | #FF9900 | |
46 | #FF6600 | |
47 | #666699 | |
48 | #969696 | |
49 | #003366 | |
50 | #339966 | |
51 | #003300 | |
52 | #333300 | |
53 | #993300 | |
54 | #993366 | |
55 | #333399 | |
56 | #333333 |
Special Characters
Character | Definition |
---|---|
0 |
Null |
a |
Alert |
b |
Backspace |
f |
Form feed |
n |
New line |
r |
Carriage return |
t |
Horizontal tab |
v |
Vertical tab |
UserAccountControl
1 2 |
# List users with "Store passwords using reversible encryption" enabled Get-ADUser -Filter 'userAccountControl -band 128' -Properties userAccountControl |
PropertyFlag | Hexadecimal | Decimal |
---|---|---|
SCRIPT | 0x0001 | 1 |
ACCOUNTDISABLE | 0x0002 | 2 |
HOMEDIR_REQUIRED | 0x0008 | 8 |
LOCKOUT | 0x0010 | 16 |
PASSWD_NOTREQD | 0x0020 | 32 |
PASSWD_CANT_CHANGE | 0x0040 | 64 |
ENCRYPTED_TEXT_PWD_ALLOWED | 0x0080 | 128 |
TEMP_DUPLICATE_ACCOUNT | 0x0100 | 256 |
NORMAL_ACCOUNT | 0x0200 | 512 |
INTERDOMAIN_TRUST_ACCOUNT | 0x0800 | 2048 |
WORKSTATION_TRUST_ACCOUNT | 0x1000 | 4096 |
SERVER_TRUST_ACCOUNT | 0x2000 | 8192 |
DONT_EXPIRE_PASSWORD | 0x10000 | 65536 |
MNS_LOGON_ACCOUNT | 0x20000 | 131072 |
SMARTCARD_REQUIRED | 0x40000 | 262144 |
TRUSTED_FOR_DELEGATION | 0x80000 | 524288 |
NOT_DELEGATED | 0x100000 | 1048576 |
USE_DES_KEY_ONLY | 0x200000 | 2097152 |
DONT_REQ_PREAUTH | 0x400000 | 4194304 |
PASSWORD_EXPIRED | 0x800000 | 8388608 |
TRUSTED_TO_AUTH_FOR_DELEGATION | 0x1000000 | 16777216 |
PARTIAL_SECRETS_ACCOUNT | 0x04000000 | 67108864 |