first commit
This commit is contained in:
parent
6b6b72a989
commit
0aa358cac1
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/.idea/
|
||||
/HyperV_PS.iml
|
91
Notes.md
Normal file
91
Notes.md
Normal file
@ -0,0 +1,91 @@
|
||||
# Powershell
|
||||
|
||||
|
||||
## Data storing
|
||||
|
||||
### Variable
|
||||
```ps
|
||||
$x="Text"
|
||||
```
|
||||
### Array
|
||||
|
||||
```ps
|
||||
$arry = @("a", "b", "c")
|
||||
```
|
||||
|
||||
## User Interaction
|
||||
|
||||
### Output
|
||||
|
||||
#### Write-Host
|
||||
|
||||
Also accepts from redirection
|
||||
|
||||
```
|
||||
Write-Host
|
||||
[[-Object] <Object>]
|
||||
[-NoNewline]
|
||||
[-Separator <Object>]
|
||||
[-ForegroundColor <ConsoleColor>]
|
||||
[-BackgroundColor <ConsoleColor>]
|
||||
[<CommonParameters>]
|
||||
```
|
||||
|
||||
|
||||
```ps
|
||||
Write-Host "text"
|
||||
```
|
||||
|
||||
#### Write-Output
|
||||
|
||||
```ps
|
||||
Write-Output "text"
|
||||
```
|
||||
|
||||
## Filtering
|
||||
|
||||
```ps
|
||||
Write-Output "text" | Select-String -pattern $filters -notMatch
|
||||
```
|
||||
## File interactions
|
||||
|
||||
### Read file
|
||||
|
||||
```ps
|
||||
Get-Contents $path
|
||||
```
|
||||
|
||||
### write to file
|
||||
|
||||
```ps
|
||||
Write-Host $text | Out-File $path
|
||||
```
|
||||
|
||||
|
||||
## Operators
|
||||
|
||||
### Looping
|
||||
|
||||
#### For
|
||||
|
||||
#### For each
|
||||
|
||||
## Management
|
||||
### Access remote PS server
|
||||
```ps
|
||||
Enter-PSSession –ComputerName $hostname [-Credential username]
|
||||
```
|
||||
> If username gets left behind, the current user will be used
|
||||
|
||||
|
||||
|
||||
# Hypver-V specific
|
||||
|
||||
## Management
|
||||
[//]: # (https://adamtheautomator.com/hyper-v-powershell/)
|
||||
|
||||
### Create new host
|
||||
New-VM -Name "HYPER" -MemoryStartupBytes 512MB
|
||||
|
||||
### List current VM
|
||||
Get-VM
|
1
Testing/simple_for.ps1
Normal file
1
Testing/simple_for.ps1
Normal file
@ -0,0 +1 @@
|
||||
## For example
|
Loading…
x
Reference in New Issue
Block a user