PowerShell Notes for Professionals
Versi ini dirapikan dan diperingkas dari dokumen PowerShell Notes for Professionals. Fokusnya adalah navigasi cepat, inti materi, dan daftar konsep/cmdlet penting per bab.
Cara Pakai Dokumen
- Gunakan Daftar Isi untuk lompat ke bab tertentu.
- Setiap bab berisi inti materi, topik/bagian, dan cmdlet/konsep cepat.
- Contoh kode tidak ditampilkan penuh agar dokumen lebih ringkas; gunakan versi lengkap jika perlu detail sintaks.
Daftar Isi
Dasar PowerShell
- Bab 1: Memulai PowerShell
- Bab 2: Variabel di PowerShell
- Bab 3: Operator
- Bab 4: Operator Khusus
- Bab 5: Operasi Set Dasar
- Bab 6: Logika Kondisional
- Bab 7: Perulangan
- Bab 8: Pernyataan Switch
- Bab 9: String
- Bab 10: HashTable
- Bab 11: Bekerja dengan Objek
- Bab 12: Fungsi PowerShell
- Bab 13: Kelas PowerShell
- Bab 14: Modul PowerShell
Objek, Modul, Pipeline, dan Data
- Bab 15: Profil PowerShell
- Bab 16: Properti Terhitung
- Bab 17: Menggunakan Kelas Statis .NET
- Bab 18: Variabel Bawaan
- Bab 19: Variabel Otomatis
- Bab 20: Variabel Lingkungan
- Bab 21: Splatting
- Bab 22: Stream PowerShell
- Bab 23: Mengirim Email
- Bab 24: PowerShell Remoting
- Bab 25: Pipeline PowerShell
- Bab 26: Background Job PowerShell
- Bab 27: Perilaku Return di PowerShell
- Bab 28: Parsing CSV
- Bab 29: Bekerja dengan File XML
Integrasi, Tooling, dan CLI
- Bab 30: RESTful API
- Bab 31: Query SQL PowerShell
- Bab 32: Regular Expression
- Bab 33: Alias
- Bab 34: Progress Bar
- Bab 35: Command-Line PowerShell.exe
- Bab 36: Penamaan Cmdlet
- Bab 37: Menjalankan Executable
- Bab 38: Prasyarat Script
- Bab 39: Sistem Bantuan
- Bab 40: Modul, Script, dan Fungsi
- Bab 41: Konvensi Penamaan
- Bab 42: Parameter Umum
- Bab 43: Parameter Set
- Bab 44: Parameter Dinamis
- Bab 45: GUI di PowerShell
- Bab 46: URL Encode/Decode
Automation, Security, Cloud, dan Enterprise
- Bab 47: Penanganan Error
- Bab 48: Manajemen Paket
- Bab 49: Komunikasi TCP
- Bab 50: Workflow PowerShell
- Bab 51: Managed Code C# / VB
- Bab 52: Download Artifact dari Artifactory
- Bab 53: Comment-Based Help
- Bab 54: Modul Archive
- Bab 55: Otomasi Infrastruktur
- Bab 56: PSScriptAnalyzer
- Bab 57: Desired State Configuration DSC
- Bab 58: ShouldProcess
- Bab 59: Scheduled Tasks
- Bab 60: Modul ISE
- Bab 61: Resource DSC Berbasis Class
- Bab 62: WMI dan CIM
- Bab 63: Modul ActiveDirectory
- Bab 64: Modul SharePoint
- Bab 65: Psake
- Bab 66: Pester
- Bab 67: Secret dan Credential
- Bab 68: Security dan Cryptography
- Bab 69: Signing Scripts
- Bab 70: Anonimisasi IP
- Bab 71: AWS Rekognition
- Bab 72: AWS S3
Bab 1: Memulai PowerShell
Inti: Fondasi PowerShell: execution policy, alias, pipeline, pemanggilan .NET, instalasi, komentar, dan pembuatan objek.
Topik penting:
- 1.1 — Allow scripts stored on your machine to run un-signed 2 …
- 1.2 — Aliases & Similar Functions 2 …
- 1.3 — The Pipeline-Using Output from a PowerShell cmdlet 3 …
- 1.4 — Calling .Net Library Methods 4 …
- 1.5 — Installation or Setup 5 …
- 1.6 — Commenting 5 …
- 1.7 — Creating Objects 6 …
Bab 2: Variabel di PowerShell
Inti: Cara menyimpan dan mengelola nilai memakai variabel, array, scope, assignment multi-variabel, dan penghapusan variabel.
Topik penting:
- 2.1 — Simple variable 7 …
- 2.2 — Arrays 7 …
- 2.3 — List Assignment of Multiple Variables 7 …
- 2.4 — Scope 8 …
- 2.5 — Removing a variable 8 …
Bab 3: Operator
Inti: Operator penting untuk perbandingan, aritmatika, assignment, redirection stream, logika, dan manipulasi string.
Topik penting:
- 3.1 — Comparison Operators 9 …
- 3.2 — Arithmetic Operators 9 …
- 3.3 — Assignment Operators 10 …
- 3.4 — Redirection Operators 10 …
- 3.5 — Mixing operand types, the type of the left operand dictates the behavior 11 …
- 3.6 — Logical Operators 11 …
- 3.7 — String Manipulation Operators 11 …
Bab 4: Operator Khusus
Inti: Operator khusus seperti array expression, call operator, dan dot sourcing untuk menjalankan script di scope tertentu.
Topik penting:
Bab 5: Operasi Set Dasar
Inti: Operasi koleksi dasar: filter, sort, group, dan select/projection objek PowerShell.
Topik penting:
- 5.1 — Filtering: Where-Object / where / ? 14 …
- 5.2 — Ordering: Sort-Object / sort 14 …
- 5.3 — Grouping: Group-Object / group 15 …
- 5.4 — Projecting: Select-Object / select 16 …
Cmdlet/konsep cepat: Where-Object, Sort-Object, Group-Object, Select-Object
Bab 6: Logika Kondisional
Inti: Pola percabangan dengan if/else/elseif, negasi, dan perilaku truthy/falsy dalam PowerShell.
Topik penting:
Bab 7: Perulangan
Inti: Teknik perulangan: foreach, for, ForEach-Object, continue, break, while, dan do/until.
Topik penting:
- 7.1 — Foreach 19 …
- 7.2 — For 19 …
- 7.3 — ForEach() Method 19 …
- 7.4 — ForEach-Object 20 …
- 7.5 — Continue 21 …
- 7.6 — Break 21 …
- 7.7 — While 22 …
- 7.8 — Do 22 …
Cmdlet/konsep cepat: ForEach-Object
Bab 8: Pernyataan Switch
Inti: Penggunaan switch untuk banyak kondisi, termasuk wildcard, regex, file input, exact match, default, dan break.
Topik penting:
- 8.1 — Simple Switch …
- 8.2 — Switch Statement with CaseSensitive Parameter …
- 8.3 — Switch Statement with Wildcard Parameter …
- 8.4 — Switch Statement with File Parameter …
- 8.5 — Simple Switch with Default Condition …
- 8.6 — Switch Statement with Regex Parameter …
- 8.7 — Simple Switch With Break …
- 8.8 — Switch Statement with Exact Parameter …
- 8.9 — Switch Statement with Expressions …
Bab 9: String
Inti: Pengolahan string: multi-line string, here-string, concatenation, karakter escape, literal string, dan format string.
Topik penting:
- 9.1 — Multiline string …
- 9.2 — Here-string …
- 9.3 — Concatenating strings …
- 9.4 — Special characters …
- 9.5 — Creating a basic string …
- 9.6 — Format string …
Bab 10: HashTable
Inti: HashTable sebagai struktur key-value: membuat, membaca, menambah, menghapus, enumerasi, dan looping.
Topik penting:
- 10.1 — Access a hash table value by key …
- 10.2 — Creating a Hash Table …
- 10.3 — Add a key value pair to an existing hash table …
- 10.4 — Remove a key value pair from an existing hash table …
- 10.5 — Enumerating through keys and Key-Value Pairs …
- 10.6 — Looping over a hash table …
Bab 11: Bekerja dengan Objek
Inti: Bekerja dengan objek: inspeksi member, menambah/menghapus properti, membuat objek custom, dan generic class.
Topik penting:
- 11.1 — Examining an object …
- 11.2 — Updating Objects …
- 11.3 — Creating a new object …
- 11.4 — Creating Instances of Generic Classes …
Bab 12: Fungsi PowerShell
Inti: Pembuatan fungsi: parameter dasar/lanjutan, mandatory parameter, validasi, dan fungsi tanpa parameter.
Topik penting:
- 12.1 — Basic Parameters …
- 12.2 — Advanced Function …
- 12.3 — Mandatory Parameters …
- 12.4 — Parameter Validation …
- 12.5 — Simple Function with No Parameters …
Bab 13: Kelas PowerShell
Inti: Class PowerShell: constructor, method, property, overload, inheritance, dan template class.
Topik penting:
- 13.1 — Listing available constructors for a class …
- 13.2 — Methods and properties …
- 13.3 — Constructor overloading …
- 13.4 — Get All Members of an Instance …
- 13.5 — Basic Class Template …
- 13.6 — Inheritance from Parent Class to Child Class …
Bab 14: Modul PowerShell
Inti: Modul PowerShell: manifest, struktur folder, ekspor fungsi/variabel, lokasi modul, dan visibilitas member.
Topik penting:
- 14.1 — Create a Module Manifest …
- 14.2 — Simple Module Example …
- 14.3 — Exporting a Variable from a Module …
- 14.4 — Structuring PowerShell Modules …
- 14.5 — Location of Modules …
- 14.6 — Module Member Visibility …
Bab 15: Profil PowerShell
Inti: Profil PowerShell untuk memuat otomatis fungsi, alias, dan konfigurasi pengguna saat shell dibuka.
Topik penting:
Bab 16: Properti Terhitung
Inti: Calculated properties untuk membentuk properti hasil kalkulasi saat memakai Select-Object.
Topik penting:
Bab 17: Menggunakan Kelas Statis .NET
Inti: Pemakaian class statis .NET seperti System.Math dan GUID dari PowerShell.
Topik penting:
Bab 18: Variabel Bawaan
Inti: Variabel bawaan penting seperti Args, ?, dan $error.
Topik penting:
Cmdlet/konsep cepat: $PSScriptRoot, $Args, $PSItem, $?, $error
Bab 19: Variabel Otomatis
Inti: Variabel otomatis seperti null, true/_/PSVersionTable.
Topik penting:
- 19.1 — $OFS …
- 19.2 — $? …
- 19.3 — $null …
- 19.4 — $error …
- 19.5 — $pid …
- 19.6 — Boolean values …
- 19.7 — PSItem …
- 19.8 — $PSVersionTable …
Cmdlet/konsep cepat: $OFS, $?, $null, $error, $pid, $_, $PSItem, $PSVersionTable
Bab 20: Variabel Lingkungan
Inti: Mengakses environment variables melalui drive Env: dan notasi $env:.
Topik penting:
- 20.1 — Windows environment variables are visible as a PS drive called Env: …
- 20.2 — Instant call of Environment Variables with $env: …
Cmdlet/konsep cepat: $env
Bab 21: Splatting
Inti: Splatting untuk mengirim banyak parameter memakai hashtable agar command lebih ringkas dan reusable.
Topik penting:
- 21.1 — Piping and Splatting …
- 21.2 — Passing a Switch parameter using Splatting …
- 21.3 — Splatting From Top Level Function to a Series of Inner Function …
- 21.4 — Splatting parameters …
Bab 22: Stream PowerShell
Inti: Stream output PowerShell: output, error, warning, verbose, debug, information, dan preference variable.
Topik penting:
Cmdlet/konsep cepat: Write-Output
Bab 23: Mengirim Email
Inti: Pengiriman email dengan Send-MailMessage dan SMTPClient.
Topik penting:
- 23.1 — Send-MailMessage with predefned parameters …
- 23.2 — Simple Send-MailMessage …
- 23.3 — SMTPClient-Mail with .txt fle in body message …
Bab 24: PowerShell Remoting
Inti: PowerShell Remoting: Enter-PSSession, Invoke-Command, serialization, trusted hosts, dan cleanup PSSession.
Topik penting:
- 24.1 — Connecting to a Remote Server via PowerShell …
- 24.2 — Run commands on a Remote Computer …
- 24.3 — Enabling PowerShell Remoting …
- 24.4 — A best practise for automatically cleaning-up PSSessions …
Bab 25: Pipeline PowerShell
Inti: Pipeline berbasis objek dan cara membuat fungsi yang menerima input pipeline.
Topik penting:
- 25.1 — Writing Functions with Advanced Lifecycle …
- 25.2 — Basic Pipeline Support in Functions …
- 25.3 — Working concept of pipeline …
Bab 26: Background Job PowerShell
Inti: Background jobs untuk menjalankan proses panjang tanpa mengunci prompt.
Topik penting:
Bab 27: Perilaku Return di PowerShell
Inti: Perilaku return dan output pipeline dalam fungsi/script PowerShell.
Topik penting:
- 27.1 — Early exit …
- 27.2 — Gotcha! Return in the pipeline …
- 27.3 — Return with a value …
- 27.4 — How to work with functions returns …
- 27.5 — Gotcha! Ignoring unwanted output …
Bab 28: Parsing CSV
Inti: Import CSV dan casting tipe data hasil Import-Csv.
Topik penting:
Cmdlet/konsep cepat: Import-Csv
Bab 29: Bekerja dengan File XML
Inti: Membaca, menulis, memanipulasi XML, XPath, namespace, dan XmlWriter.
Topik penting:
- 29.1 — Accessing an XML File …
- 29.2 — Creating an XML Document using XmlWriter() …
- 29.3 — Adding snippets of XML to current XMLDocument …
Bab 30: RESTful API
Inti: Konsumsi REST API memakai Invoke-RestMethod untuk GET, POST, PUT, dan DELETE.
Topik penting:
- 30.1 — Post Message to hipChat …
- 30.2 — Using REST with PowerShell Objects to GET and POST many items …
- 30.3 — Use Slack.com Incoming Webhooks …
- 30.4 — Using REST with PowerShell Objects to Get and Put individual data …
- 30.5 — Using REST with PowerShell to Delete items …
Bab 31: Query SQL PowerShell
Inti: Menjalankan query SQL dari PowerShell.
Topik penting:
Bab 32: Regular Expression
Inti: Regex untuk match, replace, escape karakter khusus, dan multiple matches.
Topik penting:
- 32.1 — Single match …
- 32.2 — Replace …
- 32.3 — Replace text with dynamic value using a MatchEvalutor …
- 32.4 — Escape special characters …
- 32.5 — Multiple matches …
Bab 33: Alias
Inti: Membaca dan membuat alias cmdlet.
Topik penting:
Cmdlet/konsep cepat: Get-Alias, Set-Alias
Bab 34: Progress Bar
Inti: Menampilkan progress proses dengan Write-Progress.
Topik penting:
Bab 35: Command-Line PowerShell.exe
Inti: Opsi command-line PowerShell.exe untuk menjalankan command, script, policy, profile, dan window style.
Topik penting:
Bab 36: Penamaan Cmdlet
Inti: Standar penamaan cmdlet Verb-Noun.
Topik penting:
Bab 37: Menjalankan Executable
Inti: Menjalankan aplikasi GUI/console dan membaca exit code.
Topik penting:
Bab 38: Prasyarat Script
Inti: Menetapkan prasyarat script seperti versi minimum dan administrator.
Topik penting:
- 38.1 — Enforce minimum version of PowerShell host 104 …
- 38.2 — Enforce running the script as administrator …
Bab 39: Sistem Bantuan
Inti: Memakai Get-Help, update help, contoh, full help, online help, dan parameter-specific help.
Topik penting:
- 39.1 — Updating the Help System …
- 39.2 — Using Get-Help …
- 39.3 — Viewing online version of a help topic …
- 39.4 — Viewing Examples …
- 39.5 — Viewing the Full Help Page …
- 39.6 — Viewing help for a specifc parameter …
Cmdlet/konsep cepat: Get-Help
Bab 40: Modul, Script, dan Fungsi
Inti: Perbedaan function, script, module, dan advanced function.
Topik penting:
Bab 41: Konvensi Penamaan
Inti: Konvensi penamaan fungsi agar konsisten dan mudah dipahami.
Topik penting:
Bab 42: Parameter Umum
Inti: Parameter umum seperti ErrorAction untuk mengontrol error.
Topik penting:
Bab 43: Parameter Set
Inti: Parameter set untuk membatasi kombinasi parameter dan memaksa pilihan valid.
Topik penting:
- 43.1 — Parameter set to enforce the use of a parameter when a other is selected …
- 43.2 — Parameter set to limit the combination of parameters …
Bab 44: Parameter Dinamis
Inti: Dynamic parameter untuk menambahkan parameter saat runtime.
Topik penting:
Bab 45: GUI di PowerShell
Inti: Pembuatan GUI WPF sederhana dari PowerShell.
Topik penting:
Cmdlet/konsep cepat: Get-Service
Bab 46: URL Encode/Decode
Inti: Encode dan decode URL memakai HttpUtility atau URI class.
Topik penting:
- 46.1 — Encode Query String with
[System.Web.HttpUtility]::UrlEncode()… - 46.2 — Quick Start: Encoding …
- 46.3 — Quick Start: Decoding …
- 46.4 — Encode Query String with
[uri]::EscapeDataString()… - 46.5 — Decode URL with
[uri]::UnescapeDataString()… - 46.6 — Decode URL with
[System.Web.HttpUtility]::UrlDecode()…
Bab 47: Penanganan Error
Inti: Jenis error dan dasar penanganan error.
Topik penting:
Bab 48: Manajemen Paket
Inti: Mencari, menginstall, update, dan uninstall modul PowerShell.
Topik penting:
- 48.1 — Create the default PowerShell Module Repository …
- 48.2 — Find a module by name …
- 48.3 — Install a Module by name …
- 48.4 — Uninstall a module my name and version …
- 48.5 — Update a module by name …
- 48.6 — Find a PowerShell module using a pattern …
Bab 49: Komunikasi TCP
Inti: Komunikasi TCP listener/sender menggunakan PowerShell.
Topik penting:
Bab 50: Workflow PowerShell
Inti: Workflow PowerShell untuk proses background, paralel, dan input parameter.
Topik penting:
- 50.1 — Workfow with Input Parameters …
- 50.2 — Simple Workfow Example …
- 50.3 — Run Workfow as a Background Job …
- 50.4 — Add a Parallel Block to a Workfow …
Bab 51: Managed Code C# / VB
Inti: Menyematkan kode C# atau VB.NET dengan Add-Type.
Topik penting:
Bab 52: Download Artifact dari Artifactory
Inti: Contoh script untuk mengambil artifact terbaru dari Artifactory.
Topik penting:
Bab 53: Comment-Based Help
Inti: Help berbasis komentar agar fungsi/script dapat dibaca oleh Get-Help.
Topik penting:
Bab 54: Modul Archive
Inti: Compress-Archive dan Expand-Archive untuk ZIP.
Topik penting:
- 54.1 — Compress-Archive with wildcard …
- 54.2 — Update existing ZIP with Compress-Archive …
- 54.3 — Extract a Zip with Expand-Archive …
Cmdlet/konsep cepat: Compress-Archive, Expand-Archive
Bab 55: Otomasi Infrastruktur
Inti: Otomasi infrastruktur dan contoh test integrasi black-box.
Topik penting:
Bab 56: PSScriptAnalyzer
Inti: PSScriptAnalyzer untuk static analysis script PowerShell.
Topik penting:
- 56.1 — Analyzing scripts with the built-in preset rulesets …
- 56.2 — Analyzing scripts against every built-in rule …
- 56.3 — List all built-in rules …
Bab 57: Desired State Configuration DSC
Inti: DSC untuk mendefinisikan konfigurasi target dan resource.
Topik penting:
- 57.1 — Simple example-Enabling WindowsFeature …
- 57.2 — Starting DSC (mof) on remote machine …
- 57.3 — Importing psd1 (data fle) into local variable …
- 57.4 — List available DSC Resources …
- 57.5 — Importing resources for use in DSC …
Bab 58: ShouldProcess
Inti: ShouldProcess untuk dukungan -WhatIf dan -Confirm.
Topik penting:
- 58.1 — Full Usage Example …
- 58.2 — Adding-WhatIf and-Confrm support to your cmdlet …
- 58.3 — Using ShouldProcess() with one argument …
Bab 59: Scheduled Tasks
Inti: Scheduled Tasks untuk menjalankan script PowerShell secara terjadwal.
Topik penting:
Bab 60: Modul ISE
Inti: PowerShell ISE dan fitur scripting/debugging.
Topik penting:
Bab 61: Resource DSC Berbasis Class
Inti: Membuat DSC resource berbasis class.
Topik penting:
- 61.1 — Create a DSC Resource Skeleton Class …
- 61.2 — DSC Resource Skeleton with Key Property …
- 61.3 — DSC Resource with Mandatory Property …
- 61.4 — DSC Resource with Required Methods …
Bab 62: WMI dan CIM
Inti: Query WMI/CIM, namespace, class, dan instance.
Topik penting:
Bab 63: Modul ActiveDirectory
Inti: Cmdlet ActiveDirectory untuk user, group, computer, dan object AD.
Topik penting:
Bab 64: Modul SharePoint
Inti: Modul SharePoint untuk snap-in, list, dan feature site collection.
Topik penting:
- 64.1 — Loading SharePoint Snap-In …
- 64.2 — Iterating over all lists of a site collection …
- 64.3 — Get all installed features on a site collection …
Bab 65: Psake
Inti: Psake untuk build/task automation.
Topik penting:
- 65.1 — Basic outline …
- 65.2 — FormatTaskName example …
- 65.3 — Run Task conditionally …
- 65.4 — ContinueOnError …
Bab 66: Pester
Inti: Pester untuk unit testing PowerShell.
Topik penting:
Bab 67: Secret dan Credential
Inti: Menangani credential dan secret dengan SecureString/Export-CliXml.
Topik penting:
- 67.1 — Accessing the Plaintext Password …
- 67.2 — Prompting for Credentials …
- 67.3 — Working with Stored Credentials …
- 67.4 — Storing the credentials in Encrypted form and Passing it as parameter when Required
Bab 68: Security dan Cryptography
Inti: Hashing dan kriptografi via .NET.
Topik penting:
Bab 69: Signing Scripts
Inti: Menandatangani script dan mengatur execution policy.
Topik penting:
- 69.1 — Signing a script …
- 69.2 — Bypassing execution policy for a single script …
- 69.3 — Changing the execution policy using Set-ExecutionPolicy …
- 69.4 — Get the current execution policy …
- 69.5 — Getting the signature from a signed script …
- 69.6 — Creating a self-signed code signing certifcate for testing …
Cmdlet/konsep cepat: Set-ExecutionPolicy
Bab 70: Anonimisasi IP
Inti: Anonimisasi IPv4/IPv6 dalam file teks dengan regex.
Topik penting:
Bab 71: AWS Rekognition
Inti: Contoh AWS Rekognition dari PowerShell.
Topik penting:
- 71.1 — Detect Image Labels with AWS Rekognition …
- 71.2 — Compare Facial Similarity with AWS Rekognition …
Bab 72: AWS S3
Inti: Operasi dasar AWS S3: bucket, upload, dan delete.
Topik penting:
- 72.1 — Create a new S3 Bucket …
- 72.2 — Upload a Local File Into an S3 Bucket …
- 72.3 — Delete a S3 Bucket …
