04 windows powershellスクリプト作成の基礎知識
Post on 20-Jul-2015
230 views
Embed Size (px)
TRANSCRIPT
PowerPoint
Windows PowerShell2015328 (Windows PowerShell 3I try to tease the Windows PowerShell
13 )
46 5
2Windows PowerShell
. Windows PowerShell
PowerShell
PowerShell
PowerShell
2015117124Windows PowerShellPowerShellPowerShell
PowerShellWMI(Windows Management Instrumentation)(RegistryEvent LogIISCluster etc.).NET Framework
PowerShell(PowerShell)
Get-Process
Get-Process Name explorer
Windows PowerShellPowerShell
Plain text)()
Windowsnotepad) HTML
PowerShellWindows
PowerShellPowerShell .ps1 Windows PowerShell .ps1
hogehoge_script.ps1
ps1PowerShell
PowerShellPowerShell.ps1
./ ./PowerShellTest.ps1
PowerShell
PowerShellPowerShellGet-ExecutionPolicy
PowerShellGet-ExecutionPolicyPowerShellPowerShellSet-ExecutionPolicy
RestrictedPowerShellWindows OSWindows Server 2012 R2AllSignedRemoteSignedUnrestricted BypassPowerShellPowerShellSet-ExecutionPolicy
PowerShellPowerShell
Surface RTPowerShellPowerShellPowerShellPowerShell
PowerShellPowerShell()VBScript
2{DotNetLabo}_
PowerShellPowerShell
PowerShell PowerShell
Get.Type$x = 123 $x.GetType() .NET Framework Object.GetType
PowerShellPowerShell
PowerShell Get.Type
PowerShellPowerShell
PowerShell()
PowerShell
PowerShellPowerShell
PowerShellPowerShell
Int()Int()PowerShellPowerShell
PowerShellPowerShell`n())PowerShellPowerShell6(here document)@@ @ @
$docPowerShellPowerShell
Remove-Variable
Remove-Variable abc
PowerShellPowerShellarray)
@(,,)
$array = 1,2,3,4 ,
PowerShellPowerShellassosiative array
@{=;;}LOCATIONPowerShell()PowerShellPowerShell.if)
PowerShellif , elseif , elseIf () {if elseif () {elseif} else {ifelseif}
PowerShellPowerShell.switch)
SwitchSwitch options (){{ }{ } : default{ }}PowerShellPowerShell.switch)
Switch
PowerShellPowerShell3.for)
for (; ; ){}4.while)
true()while (){}PowerShell()PowerShellExcel (csvGet-ChlidItem(Length)Excel
PowerShellExcel (csvSet-Location -path C:\work$filename = "C:\work\FolderSize.csv"
$output = Get-ChildItem | Select-Object Name,@{name="Size(byte)";expression={(Get-ChildItem $_.FullName -Recurse -Force |Measure-Object Length -Sum).Sum}}
$output | Export-Csv $filenameInvoke-Item $filenamePowerShellExcel (csvDEMOPowerShellInternet Explorer$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $true
$ie.Navigate('http://www.bing.com/')
While($ie.Busy) { [Threading.Thread]::Sleep(300) }
PowerShellInternet Explorer bing New-Object : C:\work\PS_TEST\IE.ps1:1 :7+ $ie = New-Object -ComObject InternetExplorer.Application+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (:) [New-Object], PSNotSupportedException + FullyQualifiedErrorId : CannotCreateComTypeConstrainedLanguage,Microsoft.PowerShell.Commands.NewObjectCommand
PowerShellSurface RT(Windows RT)RunSpace
Surface RTWindows RTConstraindLanguage
Windows 8FullLanguage
Constraind
1 Get-ExecutionPolicy Set-ExecutionPolicy
./ ./PowerShellTest.ps1 Windows RTWebWindows PowerShell
PowerShell@IT http://www.atmarkit.co.jp/ait/articles/1004/15/news106_2.html
PowerShell@IT http://www.atmarkit.co.jp/ait/articles/0709/20/news125.html
PowerShellCapm Network http://capm-network.com/?tag=Windows
Windows PowerShell(Code Zine) http://codezine.jp/article/detail/2388
PowerShell http://powershell.web.fc2.com/Html/Data/2011/11/03/0000.html
tech.guitarrapc.com http://tech.guitarrapc.com/
GitHubGist https://gist.github.com/n-fukuju/8487498