powershell 紹介
Post on 22-Jul-2015
376 views
Embed Size (px)
TRANSCRIPT
PowerShellLTDD #10
@tsuda_ahr
PowerShell Microsoft Shell Script
(WSH/VBScript )
Windows 7
PowerShell ISE
(Integrated Scripting Environment)
.net Script
$tcp = New-Object System.Net.Sockets.TcpClient
try {
$tcp.Connect("localhost", 445)
Write-Host ("")
} catch {
Write-Host ("")
} finally {
$tcp.Close()
$tcp.Dispose()
} host TCP Script
.net
pipe Object
(cmd.exe) (=)
Azure API
Windows Server PowerShell Script ()
) object pipe Get-Content .sample.csv |
ConvertFrom-Csv -Header @(1..50) |
Where {$_."3" -ge 1989} |
select "1","2","16","26","30" |
Out-GridView
sample.csv csv 3 1989 1,2,16,26,30GridView
1.
PS 4
.ps1
v1.0
2.
PERL
$a = 100;
if ($a > 1) {print "True";
}
PowerShell
$a = 100;
if ($a gt 1) {Write-Host "True";
}
FORTRAN
) FORTRAN 77
00010 I = 10000020 IF (I .GT. 1) THEN00030 PRINT *, "True"00040 END IF00050 END
3.
Script(.ps1)
4.
cmd /c mklink
5.Windows
API
6.
Windows
Script PowerShell
PERL
PowerShell
1) pipe
()
2) PowerShell Excel
Powershell
powershell
# Excel
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$book = $excel.Workbooks.Open("D:sample.xlsx")
$sheet = $book.Worksheets.Item("sheet1")
#
$sheet.Range("A1").Cells.Item(1, 1) = "AAA"
#
$a = $sheet.Range("A1").Cells.Item(1, 1).Text
Write-Host $a
#
$book.Save()
$excel.Quit()
# Excel.exe Powershell (
exit
3)
( .net
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "D:test"
while ($true) {
$result = $watcher.WaitForChanged([System.IO.WatcherChangeTypes]::All)
Write-Host $result.ChangeType $result.Name
}
2015/2/14 ()
http://osh-web.github.io/
PowerShell !