[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-572519-105":53,"doc-detail-572519-en":119},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":112,"head_meta":114,"extra_data":116,"updated_unix":118},105,"en","powershell-cheat-sheet-variables-arrays-strings-flow-control-operators","PowerShell Cheat Sheet - Variables - Arrays - Strings - Flow Control - Operators","","PowerShell Cheat Sheet provides a compact reference for core scripting constructs and common commands. It covers variable assignment with types, validation attributes, scopes, and global variables; array creation, indexing, slicing, flattening, and combination; associative arrays (hash tables), ordered dictionaries, and custom objects. It also summarizes string handling, comments and escape/backtick usage, control flow (if/elseif/else, loops, switch), and frequent operators for comparison and boolean logic, plus practical file and content operations.",{"@graph":63,"@context":111},[64,80,102],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/powershell-cheat-sheet-variables-arrays-strings-flow-control-operators/572519/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/powershell-cheat-sheet-variables-arrays-strings-flow-control-operators/572519.png","ImageObject",442,249,{"name":88,"@type":89},"Quinn Holloway","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-22","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":101},"InteractionCounter",{"@type":100},"ViewAction",6,{"@type":103,"mainEntity":104},"FAQPage",[105],{"name":106,"@type":107,"acceptedAnswer":108},"How do I use flow control and operators in PowerShell?","Question",{"text":109,"@type":110},"Use If/Elseif/Else for branching, while/for/foreach for looping, and Switch for pattern-based selection. Operators include comparison (eq/ne/gt/lt), boolean (and/or/not), matching (match/like/contains), and type casting with [ ].","Answer","https://schema.org",{"og:url":78,"og:type":113,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":115,"canonical":78},"index,follow",{"doc_id":117,"site_id":56},572519,1792337888,{"code":4,"msg":5,"data":120},{"doc_id":117,"user_id":121,"nickname":88,"user_avatar":122,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":123,"file_id":124,"file_url":125,"file_type":126,"file_size":127,"view_count":101,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":9,"language":128,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":129,"faqs":130,"seo_title":131,"seo_description":61,"update_tm":132,"read_time":4},2336474466712,"https://ap-avatar.wpscdn.com/davatar_a8503ba1806abce46bf441b54a3ca4cd","PowerShell Cheat Sheet  \nVariables  \n\n| $var = \"string\" | Assign variable |\n| --- | --- |\n| [Type]$var=\"typedVar\" | Assign strong typed variable |\n| [ValidateRange(1,9)][int]$x=1 | Assign strong typed attribute controlled variable |\n| $a,$b,$c = 0 or $a,$b = 'a','b' | Assign multiple variables |\n| $a,$b = $b,$a | Flip variables |\n| Scopes | global, local, private or script |\n| $global:var = \"var\" | Assign global scoped variable |\n\n\n| \"a\", \"b\", \"c\" | Array of strings |\n| --- | --- |\n| @() | Empty array |\n| 1,(2,3),4 | Array within array |\n| ,\"hi\" | Array of one element |\n| $arr[5] | Sixth element of array |\n| $arr[2..20] | Return elements 3 thru 21 |\n| $arr[ 1] | Return last array element |\n| $arr[ 3.. 1] | Display last three elements of array |\n| $arr[1,4+6..9] | Elements at index positions 1,4, 6 to 9 |\n| @(Get Process) | Force result to an array |\n| $arr[($arr. length 1) ..0] | Reverse array |\n| $arr[1] += 200 | Add to existing array item value |\n| $b = $arr[0,1 + 3..6] | New array from elements of $arr array |\n| $z = $arrA + $arrB | Combine two arrays into single array |\n\nArrays  \nAssociative Arrays (Hash tables)  \n\n| $hash = @{} | Create empty hash table |\n| --- | --- |\n| @{foo=1; bar='value2'} | Create, initialize hash table |\n| [ordered]@{a=1; b=2; c=3} | Create ordered dictionary |\n| $hash. key1 = 1 | Assign 1 to key key1 |\n| $hash.key1 | Return value of key1 |\n| $hash[\"key1\"] | Return value of key1 |\n| $hash.GetEnumerator | sort Key | Sort hash table by Key |\n| [pscustomobject]@{x=1;z=\"z\"} | Create custom object |\n\nStrings Flow Control  \nComments, Escape Characters, Backtick  \nAssignment, Logical, Comparison Operators  \nBasics of Text and Files  \nOther Operators  \n\n| Split | Split a string “abcdefghi” split “de” |\n| --- | --- |\n| join | Joins multiple strings “abc”,”def” join “;” |\n| .. | Range operator 1..10 | foreach {$_ * 5} |\n| is,-isnot | Boolean is object instance of specified . NET type |\n| as | Convert input object to specified . NET type |\n| f | Format strings 1..10 | foreach { \"{0:N2}\" f $_ } |\n| [ ] | Cast operator. [datetime]$birthday = \"1/10/66\" |\n| $( ) | Subexpression operator |\n| @( ) | Array subexpression operator |\n| & | The call/invocation operator. |\n\n\n| \"$var expand\" | String with expansion \" |\n| --- | --- |\n| '$var no expand' | String with no expansion ' |\n| @\"\u003Cbr>Here String\"@ | Here String quotes, expressions, etc. Single quotes for no expressions |\n\n\n| \\#Comment | Comment |\n| --- | --- |\n| \u003C\\# comment \\#􀀃 | Multiline comment |\n| \"A `\"test`\"\" | Escape char ` |\n| `t | Tab |\n| `n | New line |\n| ` | Line continuation |\n\n\n| If($x eq 5){} Elseif􀀅$x gt 5􀀆􀀇 􀀈 Else􀀇 􀀈 | If |\n| --- | --- |\n| $x = 1; while($x lt 10){$x;$x++} | While |\n| For($i=0; $i lt 10; $i++){ $i } | For |\n| Foreach($file in dir C:\\){$file. Name} | Foreach |\n| 1..10 | foreach{$_ } | Foreach |\n| Switch options (\u003Cvalues to switch on>){ PatternX {statement}\u003Cbr>Default {Default Statement} 􀀈 | Switch |\n\n\n| Get Location | Get current directory |\n| --- | --- |\n| Set Location | Change directory |\n| Get Content | Get content of file |\n| Add Content | Append content |\n| Set Content | Set content of file |\n| Out File | Formatted text to file |\n| Out Null | Discard output |\n| Out String | Convert to strings |\n| Copy Item | Copy items |\n| Remove Item | Remove items |\n| Move Item | Move items |\n| Rename Item | Rename item |\n| Set Item | Set contents of file |\n| Clear item | Clear contents of file |\n| New Item | New empty file or dir |\n\n\n| =,+=, =,*=,/=,%=,++, | Assign one or more values to variable |\n| --- | --- |\n| and, or, xor, not, ! | Connect expressions / statements |\n| eq, ne | Equal, not equal |\n| gt, ge | Greater than, greater than or equal |\n| lt, le | Less than, less than or equal to |\n| replace | Replacement “Hi” replace “H”,“P” |\n| match, notmatch | Regular expression match |\n| like, notlike | Wildcard matching |\n| contains, notcontains | TRUE if value on right in array on left |\n| in, notin | Reverse of contains, notcontains |\n\nFilter, ","cbCaif7j5pNpT3QS","https://ap.wps.com/l/cbCaif7j5pNpT3QS","pdf",65399,"English","# Variables\n## Arrays\n## Associative Arrays (Hash tables)\n## Strings\n## Flow Control\n## Operators and Commands","[{\"question\":\"How do I use flow control and operators in PowerShell?\",\"answer\":\"Use If/Elseif/Else for branching, while/for/foreach for looping, and Switch for pattern-based selection. Operators include comparison (eq/ne/gt/lt), boolean (and/or/not), matching (match/like/contains), and type casting with [ ].\"}]","PowerShell Cheat Sheet - Variables - Arrays - Strings - Flow Control - Operators | PDF",1791927841]