PowerShell
Lowy Shin edited this page Mar 4, 2020
·
9 revisions
-
File extension :
ps1
-
Basic execute command :
powershell -C "myshell.ps1"
-
Permission control
Get-ExcutionPolicy
-
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned -Force
- If you see permission error, then execute above once.
- It can be executed when download ps1 script
- Ref : https://github.com/LowyShin/giipdoc-ko/wiki/Powershell-%EA%B6%8C%ED%95%9C-%EB%AC%B8%EC%A0%9C-%ED%95%B4%EA%B2%B0
-
Export-Csv
- ex :
Get-EventLog system | Export-Csv -path syslog.csv -Encoding UTF8 -NoTypeInformation -Delimiter `t
-
-path
: export path -
-Encoding
:UTF8
,Default
-
-NoTypeInformation
: delete first information line#TYPE System.Diagnostics.EventLogEntry#system/Microsoft-Windows-GroupPolicy/1500
-
-Delimiter
:`t
,,
-
- ex :
-
CPU usage
$cpuinfo = New-Object -TypeName PSCustomObject
$cpu = Get-WmiObject Win32_PerfFormattedData_PerfOS_Processor | ?{$_.Name -match "^[0-9]+$"}
$cpuCnt = 0
foreach($c in $cpu)
{
$cpuinfo | Add-Member -MemberType NoteProperty -Name $c.Name -Value $c.PercentProcessorTime
$cputotal = $cputotal + $c.PercentProcessorTime
$cpuCnt = $cpuCnt + 1
}
$cputotal = $cputotal / $cpuCnt
$cputotal
# for Debug
# Write-Host "CPU Count : $cpuCnt"
# Write-Host "CPU Detail : "
# $cpuinfo
- Split files by line
# Read parent CSV
$InputFilename = Get-Content '.\source.csv'
$OutputFilenamePattern = 'output_done_'
$LineLimit = 5000
# Initialize
$line = 0
$i = 0
$file = 0
$start = 0
# Loop all text lines
while ($line -le $InputFilename.Length) {
# Generate child CSVs
if ($i -eq $LineLimit -Or $line -eq $InputFilename.Length) {
$file++
$Filename = "$OutputFilenamePattern$file.csv"
$InputFilename[$start..($line - 1)] | Out-File $Filename -Force
$start = $line;
$i = 0
Write-Host "$Filename"
}
# Increment counters
$i++;
$line++
}
- Compare contents(text) with FileA and FileB
diff (cat FileA) (cat FileB)
- Round
-
[Math]::Round( 4912.83875 , <position> )
- * 0 : 4912.83875 * 2 : 4900 * -2 : 4912.84
-
sample
$num = [Math]::Round(1.4999, -2);
- KB wiki is multi-lingual writing. If you want translate to your language, use google translate!
- Go to giip service Page : http://giipweb.littleworld.net
- Documentation : https://github.com/LowyShin/giip/wiki
- Sample automation scripts : https://github.com/LowyShin/giip/tree/gh-pages/giipscripts
See more : https://github.com/LowyShin/giip/wiki
- Token exchanges : https://tokenjar.io/GIIP
- Token exchanges manual : https://www.slideshare.net/LowyShin/giipentokenjario-giip-token-trade-manual-20190416-141149519
- GIIP Token Etherscan : https://etherscan.io/token/0x33be026eff080859eb9dfff6029232b094732c52
If you want get GIIP, contact us any time!
- LowyWorkEnv : https://github.com/LowyShin/Lowyworkenv/wiki
- CLoud RDBMS比較
- MachineLearning
- SQL Server
- ORACLE
- MySQL
- mariadh
- Redis with MySQL
- Mongodb
- Apache-Drill
- A5MK2-MultiDBMSTool
- BI
- Referrals
- Juliaの自動微分パッケージ Zygote の紹介
- color code table
- Canva - free Online Design tool
- vscode
- git(github)
- GoogleSheet
- UiPath(RPA)
- WinAutomation(official)
- Excel
- VNC
- VPN
- Note Tool
- Blog
- google news alert
- Online PDF to JPG
- LoadTest " putty
- Shell/bash
- crontab
- PowerShell
- Windows(DOS) batch
- Wscript/wsf
- AWS
- Azure
- File Sync(rsync, scp...)
- KnownPort(wikipedia)
- CentOS(Linux)
- Windows10
- Android