Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PowerShell 使っている?@Niigata.LL
Search
kasacchiful
March 23, 2013
1
870
PowerShell 使っている?@Niigata.LL
Niigata.LL で PowerShell についてしゃべりました。
kasacchiful
March 23, 2013
Tweet
Share
More Decks by kasacchiful
See All by kasacchiful
Amazon S3 TablesとAmazon S3 Metadataを動かしてみた / 20250125-niigata-5min-tech-lt
kasacchiful
0
7
dbt coreとFargateでデータ変換 / 20240928-jawsug-toyama-hokuriku-shinkansen
kasacchiful
1
83
What we keep in mind when migrating from Serverless Framework to AWS CDK and AWS SAM
kasacchiful
1
330
AWSでIcebergを使ってデータウェアハウスを構築してみる / 20240810-jawsug-akita
kasacchiful
0
38
サーバーレスパターンを元にAWS CDKでデータ基盤を構築する / 20240731_classmethod_odyssey_online_build_a_data_infrastructures_using_aws_cdk_based_on_serverless_patterns
kasacchiful
0
470
AWS IoT 1-clickがサービス終了するので、SORACOMに移行した話 / 20240518-jawsug-niigata-iotlt-niigata
kasacchiful
0
260
AWS Application Composerで始める、 サーバーレスなデータ基盤構築 / 20240406-jawsug-hokuriku-shinkansen
kasacchiful
1
570
AWSの各種サービス紹介と活用方法 − AI・ML活用デモを交えて − / 20231208aws-aiml-seminar
kasacchiful
0
530
Amazon Rekognition デモ / 20231208-aws_seminar-01-rekognition-demo
kasacchiful
0
550
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
34
1.6k
A Philosophy of Restraint
colly
203
16k
Why Our Code Smells
bkeepers
PRO
335
57k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The Cost Of JavaScript in 2023
addyosmani
47
7.2k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
For a Future-Friendly Web
brad_frost
176
9.5k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
4 Signs Your Business is Dying
shpigford
182
22k
Transcript
PowerShell ͬͯΔʁ ּݪɹ @kasacchiful
ීஈWindowsͬͯ·͔͢ʁ ࣄͰWindowsͬͯ·͔͢ʁ PowerShell ͬͨ͜ͱ͋Γ·͔͢ʁ
Windows͍ͬͯΔͳΒ PowerShellΛΘͳ͍ͱ ͍ͬͨͳ͍ʂ
࣍ ࣗݾհ PowerShellͬͯԿʁ ར ࣄྫ
ࣗݾհ ּݪɹʢ@kasacchifulʣ ৽ׁࢢࡏॅ SIerۈʢΠϯϑϥඋ͕ଟΊʣ JaSST৽ׁɹ࣮ߦҕһ ීஈMacɺࣄWindows Ruby͕͓ؾʹೖΓ ݱࡏɺපؾྍཆத…
PowerShellͬͯԿʁ
PowerShellͬͯԿʁ ੨͍ը໘ͷΠΧͭ͢ Windows7Ͱ2.0ɺ8Ͱ3.0͕ඪ४උ MSͱੑ͕ߴ͍ جຊShell͕ͩɺVBScriptͷସʹ͑Δ →ϓϩάϥϛϯάͰ͖Δͬͯ͜ͱʂ ࠓճPowerShell 2.0Λجʹ͓͠·͢
རʢݸਓతͳʣ
ར lsͬͯೖྗͰ͖Δ ͪΌΜͱදࣔ͞ΕΔ
ͦΕ͚ͩͰͳ͍
ར ΤΠϦΞε͕ొͰ͖Δ lsGet-ChildItemͷΤΠϦΞε dirGet-ChildItemͷΤΠϦΞε railsίϚϯυΛrͰొͰ͖ͳ͍
ͦΕ͚ͩͰͳ͍
ར CSVϑΝΠϧͷಡऔʗॻࠐ͕؆୯ Export-CsvɺImport-Csv σʔλ࿈ܞ͕CSVͳͷ͕ɺ͍͔ʹ SIerͬΆ͍͔ͳ
ͦΕ͚ͩͰͳ͍
ར ActiveDirectoryɺSQL Serverͷૢ࡞͕ߦ͑Δ Windows Server 2008 R2͔Β ActiveDirectoryૢ࡞ADSIΑΓ؆୯
ͦΕ͚ͩͰͳ͍
ར εΫϦϓτϑΝΠϧʹอଘɺ࣮ߦͰ͖Δ ֦ுࢠʮ.ps1ʯ όονϑΝΠϧVBScriptॻ͘͘Β͍ͳΒ PowerShellͷํ͕ศར
ͦΕ͚ͩͰͳ͍
ར .NET FrameworkͷΫϥεϥΠϒϥϦ͕ ͑Δ Windows FormWPF͑ͯ͠·͏ => ԿͰͰ͖ͦ͏͡ΌΜʂ
ͦΕ͚ͩͰͳ͍
ར ύΠϓ͕͑Δ UnixʗLinuxͰͨΓલ PowerShellͰɺ.NET FrameworkͷΦϒδΣΫτ͕͞ΕΔ
ύΠϓͷྫ ࠷ऴߋ৽͕ݱࡏͷ0:00:00ΑΓ30Ҏ্ܦաͨ͠ ʮ.logʯϑΝΠϧΛআ͢Δ ls “C:¥log” | where {($_.Name -match “.log$”)
-and ($_.LastWriteTime -lt (Get-Date -Hour 0 -Minute 0 -Second 0).AddDays(-30))} | rm
ͦΕ͚ͩͰͳ͍
ར ΦϒδΣΫτࢦϓϩάϥϛϯά ϓϩτλΠϓϕʔε ΧελϜΦϒδΣΫτΛ࡞ͯ͠ϓϩύςΟͱ ϝιουΛՃ͢Δํ๏ͰՄೳ
ΦϒδΣΫτࢦϓϩάϥϛϯάͷྫ $i = 1; $i.PSObject.Members.Add( (New-Object System.Management.Automation.PSScriptMethod “Hello”, {param($msg); “Hello,
$msg $this.”}) ); $i.Hello(“My name is”) => Hello, My name is 1.
ͦΕ͚ͩͰͳ͍
͚ͩͲ͍ͷͰলུ ʮPowerShell ISEʯͱ͍͏։ൃڥ͕͑Δ σόοάػೳ͕ඪ४උ Windows 7ΫϥΠΞϯτ͔ΒϦϞʔτͷWindows 2008 R2αʔόϦϞʔ τཧػೳ ύΠϓͱ࿈ܞ֤ͯ͠छϑΟϧλػೳ͕ڧྗ
୯ମςετπʔϧ͑ΔʢPSUnitͳͲʣ ྫ֎ॲཧʮtryʯʮcatchʯʮfinallyʯ etc.
ͳΜ͔ͩLLͬΆ͍Ͱ͢ΑͶ
ࣄྫ
ࣄྫ ৬һཧ༻ActiveDirectoryͷҟಈॲཧ ҟಈ͢Δͱॴଐ͢Δ෦ॺʹରԠ͢ΔOUͱηΩϡϦςΟάϧʔϓΛCSV࿈ܞ ͱPowerShellͰ͝Γ͝Γมߋ Ϣʔβͷ৽نొɺมߋɺআΔ
ࣄྫ ਓࣄڅ༩γεςϜ ౷߹ೝূγεςϜ ใܥAD جװܥAD ͦͷଞαϒγεςϜ ͜ͷ࿈ܞ෦
ͬͨ͜ͱ ౷߹ೝূγεςϜ͔ΒCSVϑΝΠϧΛड͚औΔ ใܥActiveDirectoryαʔόͰɺͦΕΛPowerShellͰ͝Γ͝Γ ใܥADΛมߋ
εΫϦϓτͰͬͨ͜ͱ 1.ϑΝΠϧબμΠΞϩάදࣔ • Windows Form ͔Β FileDialogݺग़ 2.CSVऔࠐ 3.ActiveDirectoryૢ࡞ 4.ϩάग़ྗ
• Τϥʔ͕ग़ͨΒɺPowerShellͷਖ਼نදݱͰ֬ೝ
Windows͍ͬͯΔͳΒ PowerShellΛΘͳ͍ͱ ͍ͬͨͳ͍ʂ