Skip to content

Instantly share code, notes, and snippets.

@oculushut
Last active March 18, 2016 17:10
Show Gist options
  • Save oculushut/003c0753f1790fa11a6b to your computer and use it in GitHub Desktop.
Save oculushut/003c0753f1790fa11a6b to your computer and use it in GitHub Desktop.
PowerShell Cheat Sheet
CREATE NEW FILE:
New-Item [filename/path] type=file
SEE IF FILE EXISTS
Test-Path [filename/path]
SEE FILE CONTENT
Get-Content [filename/path]
WRITE DATA IN FILE
Set-Content [filename] [content]
MAKING A WEB REQUEST
PS C:\Users\Administrator\chef-repo> Invoke-WebRequest localhost
StatusCode : 200
StatusDescription : OK
Content : <html>
<body>
<h1>hello world</h1>
</body>
</html>
RawContent : HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 58
Content-Type: text/html
Date: Fri, 18 Mar 2016 17:09:00 GMT
ETag: "5b396ebd3881d11:0"
Last-Modified: Fri, 18 Mar 2016 17:08:06 GMT
Server...
Forms : {}
Headers : {[Accept-Ranges, bytes], [Content-Length, 58], [Content-Type, text/html], [Date, Fri, 18 Mar 2016 17:09:00 GMT]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : System.__ComObject
RawContentLength : 58
PS C:\Users\Administrator\chef-repo> (Invoke-WebRequest localhost).Content
<html>
<body>
<h1>hello world</h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment