[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-572384-105":53,"doc-detail-572384-en":127},{"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":120,"head_meta":122,"extra_data":124,"updated_unix":126},105,"en","powershell-cheat-sheet","PowerShell Cheat Sheet","","PowerShell Cheat Sheet provides compact, practical notes and examples for common scripting tasks. It covers running scripts via PowerShell, defining arrays and variables, typing values with .NET types, using constants, and referencing elements. It also summarizes function syntax, creating COM and .NET objects, passing command-line arguments, writing console output, capturing user input, formatting pipelines, and essential cmdlets like Get-Help, Get-Command, and Get-Member.",{"@graph":63,"@context":119},[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/572384/",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/572384.png","ImageObject",442,249,{"name":88,"@type":89},"McGucket","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",8,{"@type":103,"mainEntity":104},"FAQPage",[105,111,115],{"name":106,"@type":107,"acceptedAnswer":108},"How do you execute a PowerShell script and keep the session open?","Question",{"text":109,"@type":110},"Use powershell.exe with -noexit and run the script from its path, e.g., powershell.exe –noexit & \"c:\\[myscript.ps1](myscript.ps1)\".","Answer",{"name":112,"@type":107,"acceptedAnswer":113},"How are arrays, variables, and constants handled in the cheat sheet?",{"text":114,"@type":110},"Constants are created without $ and set via Set-Variable –name b –value ... –option constant, then referenced with $b.",{"name":116,"@type":107,"acceptedAnswer":117},"Which cmdlets are listed as essential for help and discovery?",{"text":118,"@type":110},"The sheet highlights Get-Help for learning a cmdlet, Get-Command for listing cmdlets, and Get-Member for properties and methods (often piped with Get-Service | Get-Member).","https://schema.org",{"og:url":78,"og:type":121,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":123,"canonical":78},"index,follow",{"doc_id":125,"site_id":56},572384,1792019206,{"code":4,"msg":5,"data":128},{"doc_id":125,"user_id":129,"nickname":88,"user_avatar":130,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":101,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":73,"language":136,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":60,"faqs":137,"seo_title":138,"seo_description":61,"update_tm":139,"read_time":9},1236954412713,"https://us-avatar.wpscdn.com/davatar_29158cc5080c5b710cf443261637dec0","To Execute Script  \npowershell.exe –noexit &”c:\\[myscript.ps1](myscript.ps1)”  \nArrays  \nTo initialise  \n$a = 1,2,4,8 To query  \n$b = $a[3]  \nVariables  \nMust start with $$a = 32  \nCan be typed  \n[int]$a = 32  \nConstants  \nCreated without $  \nSet-Variable –name b –value 3.142 –option constant Referenced with $  \n$b  \nFunctions  \nParameters separate by space. Return is optional.  \nfunction sum ([int]$a,[int]$b){  \nreturn $a + $b}  \nsum 4 5  \nCreating Objects  \nTo create an instance of a com object New-Object-comobject \u003CProgID>  \n$a = New-Object –comobject \"[wscript.network](wscript.network)\"$a.username  \nTo create an instance of a . Net Framework object. Parameters can be passed if required New-Object –type \u003C.Net Object>  \n$d = New-Object -Type System.DateTime 2006,12,25 $d.get_DayOfWeek()  \nPassing Command Line Arguments  \nPassed to script with spaces  \n[myscript.ps1](myscript.ps1) server1 benp  \nAccessed in script by $args array  \n$servername = $args[0]  \n$username = $args[1]  \nMiscellaneous  \nLine Break `  \nGet-Process | Select-Object ` name, ID  \nComments \\#  \n\\# code here not executed  \nMerging lines ;  \n$a=1;$b=3;$c=9  \nPipe the output to another command |  \nGet-Service | Get-Member  \nEssential Commands  \nTo get help on any cmdlet use get-help  \nGet-Help Get-Service  \nTo get all available cmdlets use get-command  \nGet-Command  \nTo get all properties and methods for an object use get-member Get-Service | Get-Member  \nSetting Security Policy  \nView and change execution policy with GetExecution and Set-Execution policy  \nGet-Executionpolicy  \nSet-Executionpolicy remotesigned  \nPowerShell Cheat Sheet  \nWriting to Console  \nVariable Name  \n$a  \nor  \nWrite-Host $a –foregroundcolor “green”  \nCapture User Input  \nUse Read-Host to get user input  \n$a = Read-Host “Enter your name”Write-Host \"Hello\" $a  \n\n|  |  |  |  |  |  |  |  |  |  |  |  |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n|  |  | ile Loop\u003Cbr>at a set of commands while a condition is met\u003Cbr>a++} a –lt 10) |  | |  |  | Do Until Loop\u003Cbr>Can repeat a set of commands until a co $a=1\u003Cbr>Do {$a; $a++} Until ($a –gt 10) |  |  |  |  |\n| Do Wh\u003Cbr>Can repe $a=1 Do {$a; $\u003Cbr>While ($ |  |  |  |  |  |  |  |  | ndition is met |  |  |\n| \u003Cbr>\u003Cbr>\u003Cbr>ForEach-Loop Through Collection of Objects\u003Cbr>Loop through a collection of objects\u003Cbr>Foreach ($i in Get-Childitem c: \\windows){$ [i.name](i.name) ; $i.creationtime}\u003Cbr>\u003Cbr>\u003Cbr>\u003Cbr>\u003Cbr>Switch Statement\u003Cbr>Another method to run a specific set of code given specific conditions\u003Cbr>$a = \"red\"\u003Cbr>switch ($a){\u003Cbr>\"red\" {\"The colour is red\"}\"white\"{\"The colour is white\"} default{\"Another colour\"}\u003Cbr>} |  |  |  |  |  |  |  |  |  |  |  |\n|  |  |  |  |  |  |  |  |  |  |  |  |\n|  |  |  |  |  |  |  |  |  |  |  |  |\n|  | Reading From a F\u003Cbr>Use Get-Content to cr through array\u003Cbr>$a = Get-Conten foreach ($i in {$i} |  | ile\u003Cbr>eate an array of lines. Then loop\u003Cbr>t \"c: \\ servers.txt\"$a) |  |  | Writing to a Simple File\u003Cbr>Use Out-File or > for a simple text $a = \"Hello world\"\u003Cbr>$a | out-file test.txt\u003Cbr>Or use > to output script results to.\\[test.ps1](test.ps1) > test.txt |  | file\u003Cbr>file |  |  |  |\n| \u003Cbr>\u003Cbr>Writing to an Html File\u003Cbr>Use ConvertTo-Html and >\u003Cbr>$a = Get-Process\u003Cbr>$a | Convertto-Html -property Name,Path,Company > test.htm\u003Cbr>\u003Cbr>\u003Cbr>Writing to a CSV File\u003Cbr>Use Export-Csv and Select-Object to filter output\u003Cbr>$a = Get-Process\u003Cbr>$a | Select-Object Name,Path,Company | Export-Csv -path test.csv |  |  |  |  |  |  |  |  |  |  |  |","cbCairsgsvorOFal","https://ap.wps.com/l/cbCairsgsvorOFal","pdf",282505,"English","[{\"question\":\"How do you execute a PowerShell script and keep the session open?\",\"answer\":\"Use powershell.exe with -noexit and run the script from its path, e.g., powershell.exe –noexit \\u0026 \\\"c:\\\\[myscript.ps1](myscript.ps1)\\\".\"},{\"question\":\"How are arrays, variables, and constants handled in the cheat sheet?\",\"answer\":\"Constants are created without $ and set via Set-Variable –name b –value ... –option constant, then referenced with $b.\"},{\"question\":\"Which cmdlets are listed as essential for help and discovery?\",\"answer\":\"The sheet highlights Get-Help for learning a cmdlet, Get-Command for listing cmdlets, and Get-Member for properties and methods (often piped with Get-Service | Get-Member).\"}]","PowerShell Cheat Sheet | PDF",1791927093]