Daftar Periksa Kepatuhan HIPAA dan Alat untuk Digunakan
Jika Anda berada di industri kesehatan atau entah bagaimana terlibat dengan TI di industri itu, kemungkinan Anda pernah mendengar tentang HIPAA. Portabilitas Asuransi Kesehatan
Jika Anda adalah pengguna kekuatan Windows, Anda mungkin tahu dan memahami bagaimana melakukan berbagai operasi pada PC Anda dapat memiliki lebih dari satu pendekatan dan bahwa aplikasi GUI khusus seringkali lebih membatasi (dan kurang memuaskan, jujur saja) daripada memasukkan perintah di baris perintah secara manual. Hanya ada perasaan puas ketika Anda melihat dinding teks terbentang di depan Anda, dan jika hasilnya bukan kesalahan, itu membuatnya lebih berharga.
Pada PC Windows, hanya ada dua cara untuk mencapai ini: melalui CMD atau PowerShell. Meskipun CMD sedikit lebih populer daripada PowerShell, itu juga kurang kuat, mengingat bahwa mitranya memungkinkan Anda untuk melakukan lebih banyak operasi, termasuk yang dapat Anda jalankan melalui CMD. Anda dapat mengatakan bahwa PowerShell menggabungkan kekuatan CMD lama dengan kemampuan skrip dan cmdlet, memberi Anda banyak kemungkinan terkait operasi yang dapat Anda lakukan dengannya.
Namun, banyaknya kemungkinan operasi yang dapat Anda lakukan dengan menggunakan PowerShell bisa sangat menakutkan bahkan untuk pengguna berpengalaman, belum lagi pengguna yang belum pernah mendengar tentang CMD (apalagi PowerShell) sebelumnya. Namun, jangan khawatir, kami akan mencoba dan mengajari Anda beberapa trik mudah yang dapat Anda lakukan dengan PowerShell dan bahkan mungkin diingat dalam jangka panjang. Meskipun "kursus kilat" kami ini tidak akan berfungsi sebagai manual komprehensif untuk PowerShell, semoga ini akan membantu Anda menemukan jalan di sekitar PowerShell dengan memberi Anda beberapa petunjuk dan menjelaskan banyak perintah. Jika Anda siap, mari kita mulai.
Apa itu PowerShell?
Seperti yang telah kami sebutkan secara singkat di atas, PowerShell adalah alat yang ampuh yang dapat Anda gunakan untuk berbagai macam operasi. Lebih dari itu, PowerShell adalah solusi otomatisasi tugas yang terdiri dari beberapa alat canggih di bawah kapnya, termasuk tetapi tidak terbatas pada shell baris perintah (seperti CMD), bahasa skrip, serta kerangka kerja manajemen konfigurasi.
Berbeda dengan shell lain yang hanya dapat menerima dan mengembalikan teks, PowerShell juga dapat menerima dan mengembalikan objek .NET berkat sejumlah fitur luar biasa yang dicakupnya. Beberapa fitur terkait shell yang paling penting dari PowerShell adalah sebagai berikut:
Namun, itu hanya menggores puncak gunung es karena, seperti yang telah kami sebutkan sebelumnya, PowerShell lebih dari sekadar cangkang; Anda dapat menggunakannya sebagai bahasa skrip yang kuat untuk mengotomatisasi operasi manajemen sistem, tetapi juga jika Anda ingin membangun, menganalisis, menguji, dan menerapkan solusi di berbagai lingkungan.
Mengingat bahwa PowerShell didasarkan pada .NET CLR (.NET Common Language Runtime), mudah untuk melihat mengapa semua input dan output yang digunakan PowerShell adalah objek .NET. Selain itu, sama sekali tidak perlu mengurai keluaran teks hanya agar PowerShell dapat mengekstrak informasi darinya. Di antara fitur skrip PowerShell, Anda mungkin menemukan yang berikut:
Jika Anda lebih tertarik untuk mengelola dan mengonfigurasi infrastruktur perusahaan Anda melalui kode, Anda akan senang mengetahui bahwa PowerShell juga menawarkan kemungkinan ini kepada Anda melalui kerangka kerja manajemen Desired State Configuration (DSC). Di antara operasi yang dapat Anda lakukan dengan mudah dengan memanfaatkan DSC PowerShell, kami mengingatkan Anda tentang:
PowerShell memiliki baris perintah berpemilik yang hadir dengan bahasa pemrograman berpemilik yang agak mirip dengan Perl. Perhatikan bahwa pada awalnya, PowerShell dikembangkan untuk membantu pengguna mengelola objek di komputer mereka, tetapi, seperti yang dapat Anda bayangkan, PowerShell telah berkembang pesat dan sekarang digunakan untuk pekerjaan yang lebih luas dan kompleks.
Misalnya, Anda dapat menggunakan lingkungan kerja PowerShell yang luas tidak hanya untuk melakukan berbagai operasi manajemen sistem tetapi juga untuk mengotomatiskannya sehingga Anda tidak perlu terlibat dalam tugas yang membosankan dan berulang sesekali. Juga cukup penting untuk disebutkan bahwa Anda dapat mengakses banyak sumber daya hanya melalui satu program (yaitu PowerShell), termasuk, namun tidak terbatas pada:
Saat ini, salah satu tujuan PowerShell yang paling populer adalah membantu pengguna akhir mengotomatiskan tugas manajemen sistem, sehingga membantu mereka menghindari serangkaian operasi yang membosankan dan berulang. Menghilangkan faktor manusia dari tindakan berulang telah terbukti meningkatkan efisiensi dan mengurangi kesalahan manusia karena berbagai alasan, jadi ini benar-benar win-win untuk semua orang.
Anda dapat menggunakan PowerShell untuk mengeluarkan perintah sederhana atau lebih kompleks, tetapi program ini juga dapat membantu Anda membuat skrip berdasarkan perintah tersebut, yang akan dijalankan secara otomatis oleh PowerShell. Selain itu, ada sejumlah besar perintah yang dapat Anda sesuaikan dan keluarkan kemudian yang disebut cmdlet.
Perlu disebutkan bahwa PowerShell adalah lintas platform dan sumber terbuka, artinya Anda juga dapat menggunakannya di sistem lain seperti Mac atau Linux secara asli, tanpa menggunakan trik dan alat peningkatan kompatibilitas seperti Wine atau Boot Camp.
Daftar Perintah Dasar PowerShell
Kami memahami bahwa PowerShell mungkin terasa sedikit menakutkan, terutama sekarang setelah Anda mengetahui bahwa itu lebih dari sekadar prompt perintah lain di komputer Anda, dan itu sebenarnya mencakup fitur CMD, tetapi juga bahasa pemrograman tertentu dan berbagai skrip yang dapat Anda gunakan untuk mengotomatisasi operasi manajemen sistem.
Namun, jika Anda merasa bertekad untuk menguasai PowerShell dan semua yang ditawarkannya, kami sangat menyarankan Anda memulai dengan fitur paling dasar. Dengan begitu Anda tidak perlu memutar kembali kemajuan berbulan-bulan ketika Anda menemukan bahwa Anda secara tidak sengaja menggunakan fungsi yang salah dan semua pekerjaan yang Anda lakukan sementara itu mulai terlihat lebih seperti memori yang jauh.
Itulah mengapa kami telah menyiapkan daftar perintah dasar yang dapat Anda gunakan dengan aman dalam sesi PowerShell Anda untuk menguji fitur program canggih ini dan melihat mana yang melakukan apa. Daftar di bawah ini terdiri dari nama-nama perintah, alias mereka, dan deskripsi singkat tentang apa yang dilakukan setiap perintah.
Perhatikan bahwa Anda dapat menggunakan nama perintah atau aliasnya, dan hasilnya akan sama persis. Alasan mengapa seseorang lebih suka menggunakan alias adalah karena mereka jauh lebih cepat untuk diketik dan jika Anda dapat mengingatnya dengan benar dan mengaitkannya dengan nama perintah yang sesuai, akan lebih masuk akal jika Anda ingin menyelesaikan pekerjaan dengan cepat.
Nama perintah | Alias | Keterangan |
---|---|---|
Tambah isi | ac | Memungkinkan Anda menambahkan konten (misalnya kata, atau data) ke file |
Tambahkan-PSSnapIn | asnp | Membantu Anda menambahkan beberapa snap-in Windows PowerShell ke sesi saat ini |
Jelas-Konten | clc | Menghapus isi item tanpa menghapus item yang sebenarnya |
Hapus-Sejarah | klise | Menghapus setiap dan semua entri dari riwayat perintah |
Hapus-Host | jernih | Membersihkan tampilan program host |
Hapus-Host | cls | Melakukan hal yang sama dengan clear |
Hapus-Item | kli | Menghapus isi item tanpa menghapus item yang sebenarnya |
Clear-ItemProperty | klp | Menghapus nilai properti tanpa benar-benar menghapus properti itu sendiri |
Hapus-Variabel | clv | Menghapus nilai variabel |
Bandingkan-Obyek | membandingkan | Memungkinkan Anda membandingkan dua set objek |
Bandingkan-Obyek | berbeda | Melakukan hal yang sama seperti membandingkan |
Connect-PSSession | cnsn | Memungkinkan Anda menyambung kembali ke sesi yang telah Anda putuskan |
Konversi-Jalur | cvpa | Memungkinkan Anda mengubah jalur Windows PowerShell menjadi jalur penyedia Windows PowerShell |
Salin-Item | salinan | Membantu Anda menyalin item dari lokasi tertentu ke lokasi lain |
Salin-Item | cp | Melakukan hal yang sama seperti menyalin |
Salin-Item | cpi | Melakukan hal yang sama seperti menyalin dan cp |
Salin-ItemProperti | cpp | Memungkinkan Anda menyalin nilai dan properti dari lokasi tertentu ke satu yang berbeda |
Nonaktifkan-PSBreakpoint | dbp | Membantu Anda menonaktifkan breakpoint di konsol saat ini |
Putus-PSSession | dnsn | Memutuskan Anda dari sesi saat ini |
Aktifkan-PSBreakpoint | ebp | Memungkinkan Anda mengaktifkan breakpoint di konsol saat ini |
Masuk-PSSession | etsn | Membantu Anda meluncurkan sesi interaktif dengan perangkat jarak jauh |
Keluar-PSSesi | exsn | Mengakhiri sesi interaktif dengan perangkat jarak jauh |
Ekspor-Alias | epal | Memungkinkan Anda mengekspor informasi tentang alias yang saat ini ditentukan ke file keluaran |
Ekspor-Csv | epcsv | Memungkinkan Anda mengonversi objek menjadi beberapa string yang dipisahkan koma (CSV) dan mengekspor string tersebut ke dokumen CSV |
Ekspor-PSSesi | epsn | Mengimpor perintah dari sesi yang berbeda dan mengekspornya ke modul Windows PowerShell |
Untuk Setiap-Obyek | % | Melakukan operasi tertentu terhadap masing-masing item yang terkandung dalam kumpulan objek input |
Untuk Setiap-Obyek | untuk setiap | Melakukan hal yang sama dengan % |
Format-Kustom | fc | Membantu Anda menggunakan tampilan yang disesuaikan untuk memformat output |
Format-Daftar | fl | Memungkinkan Anda memformat output sebagai daftar properti di mana setiap properti ditempatkan pada baris baru |
Format-Tabel | kaki | Memungkinkan Anda memformat output sebagai tabel |
Format-Lebar | fw | Membantu Anda memformat objek sebagai tabel lebar di mana hanya satu properti dari setiap objek yang ditampilkan |
Dapatkan-Alias | cewek | Mengambil Anda alias untuk sesi Anda saat ini |
Dapatkan-AnakItem | dir | Mengambil daftar semua file dan folder di drive sistem file |
Dapatkan-AnakItem | gci | Melakukan hal yang sama seperti dir |
Dapatkan-AnakItem | ls | Melakukan hal yang sama seperti dir dan gci |
Dapatkan-Perintah | gcm | Mengambil daftar semua perintah yang dapat Anda gunakan |
Dapatkan-Konten | kucing | Menampilkan isi file |
Dapatkan-Konten | gc | Melakukan hal yang sama seperti kucing |
Dapatkan-Sejarah | ghy | Mengambil daftar semua perintah yang Anda masukkan selama sesi Anda saat ini |
Dapatkan-Sejarah | H | Melakukan hal yang sama dengan ghy |
Dapatkan-Sejarah | sejarah | Melakukan hal yang sama seperti ghy dan h |
Dapatkan-Item | gi | Memungkinkan Anda mengambil file dan folder |
Dapatkan-ItemProperty | gp | Mengambil properti dari item yang Anda tentukan |
Mendapat pekerjaan | gjb | Mengambil daftar semua pekerjaan latar belakang Windows PowerShell yang sedang berjalan di sesi Anda |
Dapatkan-Lokasi | gl | Mengambil informasi tentang tumpukan lokasi Anda saat ini atau lokasi kerja |
Dapatkan-Lokasi | pwd | Melakukan hal yang sama seperti gl |
Dapatkan-Member | gm | Mengambil semua properti dan metode objek tertentu |
Dapatkan-Modul | transgenik | Mengambil daftar modul yang diimpor atau modul yang dapat diimpor ke sesi saat ini |
Dapatkan-Proses | gps | Mengambil daftar semua proses yang berjalan secara lokal atau pada komputer jarak jauh |
Dapatkan-Proses | ps | Melakukan hal yang sama seperti gps |
Dapatkan-PSBreakpoint | Pound Sterling | Mengambil semua breakpoint yang disetel di sesi Anda saat ini |
Dapatkan-PSCallStack | gcs | Menampilkan tumpukan panggilan Anda saat ini |
Dapatkan-PSDrive | gdr | Mengambil drive di sesi Anda saat ini |
Dapatkan-PSSession | gsn | Mengambil daftar sesi Windows PowerShell lokal dan jarak jauh |
Dapatkan-PSSnapIn | gsnp | Mengambil daftar semua snap-in Windows PowerShell di komputer |
Dapatkan-Layanan | gsv | Mencantumkan semua layanan di komputer lokal atau jarak jauh |
Dapatkan-Unik | gu | Mengambil item unik dari daftar yang diurutkan |
Dapatkan-Variabel | gv | Menampilkan daftar semua variabel di konsol saat ini |
Dapatkan-WmiObject | gwmi | Mengambil instance kelas Windows Management Instrumentation (WMI) atau informasi tentang kelas yang tersedia |
Grup-Objek | kelompok | Memungkinkan Anda mengelompokkan objek yang berisi nilai yang sama untuk properti yang Anda tentukan |
Tolong | manusia | Menampilkan detail lebih lanjut tentang perintah dan konsep Windows PowerShell |
Impor-Alias | ipal | Memungkinkan Anda mengimpor daftar alias dari file |
Impor-Csv | ipcsv | Bangun objek khusus seperti tabel menggunakan semua item yang ada dalam file CSV |
Impor-Modul | ipmo | Impor modul ke sesi Anda saat ini |
Impor-PSSes sion | ipsn | Mengimpor perintah dari sesi berbeda ke sesi Anda saat ini |
Invoke-Command | icm | Memungkinkan Anda menjalankan perintah pada komputer lokal dan jarak jauh |
Panggil-Ekspresi | contoh | Memungkinkan Anda menjalankan perintah atau ekspresi di komputer lokal |
Invoke-History | ihy | Menjalankan perintah dari riwayat sesi Anda |
Invoke-History | R | Melakukan hal yang sama seperti ihy |
Invoke-Item | ii | Melakukan tindakan default pada item tertentu |
Metode Invoke-Istirahat | irm | Mengirim permintaan HTTP atau HTTPS ke layanan web RESTful |
Invoke-WebRequest | keriting | Mengambil konten dari halaman web di Internet |
Invoke-WebRequest | iwr | Melakukan hal yang sama seperti curl |
Invoke-WMIMetode | iwmi | Memungkinkan Anda untuk memanggil metode Windows Management Instrumentation (WMI) |
Ukur-Objek | ukuran | Menentukan properti numerik objek, serta kata, garis, dan karakter dalam objek string |
mkdir | md | Membuat item baru (direktori) |
Pindah-Item | mi | Memungkinkan Anda memindahkan item dari lokasi tertentu ke lokasi lain |
Pindah-Item | bergerak | Melakukan hal yang sama seperti mi |
Pindah-Item | mv | Melakukan hal yang sama seperti mi dan bergerak |
Pindah-ItemProperti | mp | Memungkinkan Anda memindahkan properti dari lokasi tertentu ke lokasi lain |
Baru-Alias | akhir | Memungkinkan Anda membuat alias baru |
Barang baru | ni | Memungkinkan Anda membuat item baru |
Baru-Modul | nmo | Menghasilkan modul dinamis baru yang hanya ada di memori |
PSDrive Baru | Gunung | Memungkinkan Anda membuat drive jaringan yang dipetakan sementara dan persisten |
PSDrive Baru | ndr | Melakukan hal yang sama seperti mount |
PSSesi Baru | nsn | Membuat koneksi persisten ke komputer lokal atau jarak jauh |
File Konfigurasi-PSSes Baru | npssc | Membuat file konfigurasi sesi |
Variabel Baru | nv | Memungkinkan Anda membuat variabel baru |
Tampilan Luar Jaringan | ogv | Memungkinkan Anda mengirim output ke tabel interaktif di jendela terpisah |
Tuan Rumah Luar | Oh | Mengirim output ke baris perintah (CMD) |
Out-Printer | lp | Memungkinkan Anda mengirim output ke printer |
Lokasi Pop | popd | Memodifikasi lokasi Anda saat ini ke lokasi yang didorong ke tumpukan paling baru. Anda dapat menggunakan Push-Locationcmdlet ( pushd ) untuk memunculkan lokasi baik tumpukan defaultnya atau dari tumpukan yang Anda buat. |
powershell_ise.exe | ise | Menampilkan penjelasan tentang bagaimana Anda dapat menggunakan alat baris perintah PowerShell_ISE.exe |
Lokasi Dorong | mendorong | Menambahkan lokasi saat ini ke bagian atas tumpukan lokasi |
Terima-Pekerjaan | rcjb | Mengambil hasil pekerjaan latar belakang Windows PowerShell sesi saat ini |
Terima-PSSesi | rcsn | Mengambil hasil perintah dari sesi yang terputus |
Hapus-Item | del | Menghapus file dan folder |
Hapus-Item | menghapus | Melakukan hal yang sama seperti del |
Hapus-Item | rd | Melakukan hal yang sama seperti del dan menghapus |
Hapus-Item | ri | Does the same thing as del, erase and rd |
Remove-Item | rm | Does the same thing as del, erase, rd, and ri |
Remove-Item | rmdir | Deletes folders |
Remove-ItemProperty | rp | Allows you to delete a property and its value from a given item |
Remove-Job | rjb | Lets you delete a Windows PowerShell background job |
Remove-Module | rmo | Helps you remove modules from your current session |
Remove-PSBreakpoint | rbp | Lets you remove breakpoints from the current console |
Remove-PSDrive | rdr | Removes temporary Windows PowerShell drives, as well as disconnects mapped network drives |
Remove-PSSession | rsn | Lets you close one or more Windows PowerShell sessions (PSSessions) |
Remove-PSSnapin | rsnp | Enables you to remove Windows PowerShell snap-ins from your current session |
Remove-Variable | rv | Clears a variable and its value |
Remove-WMIObject | rwmi | Lets you delete an instance of an existing Windows Management Instrumentation (WMI) class |
Rename-Item | ren | Helps you rename an item in a Windows PowerShell provider namespace |
Rename-Item | rni | Does the same thing as ren |
Rename-ItemProperty | rnp | Enables you to rename an item’s property |
Resolve-Path | rvpa | Resolves wildcard characters in a path, as well as displays the contents of the path |
Resume-Job | rujb | Helps you restart a job that was suspended |
Select-Object | select | Lets you select objects as well as their properties |
Set-Alias | sal | Lets you create or change a cmdlet’s or command element’s alias (alternate name) in the current Windows PowerShell session |
Set-Content | sc | Allows you to replace a file’s contents with contents that you specify. |
Set-Item | si | Changes an item’s value to a value that’s specified in the command |
Set-Location | cd | Lets you set your current working location to a specified location (changes the active location) |
Set-Location | chdir | Does the same thing as cd |
Set-PSBreakpoint | sbp | Lets you set a breakpoint on a command, variable, or line |
Set-Variable | set | Enables you to set a variable’s value or generates a variable if one with the requested name does not exist |
Show-Command | shcm | Displays a list of Windows PowerShell commands in a graphical command window |
Start-Job | sajb | Starts a background job in Windows PowerShell |
Start-Process | saps | Launches one or more local processes |
Start-Service | sasv | Lets you start one or more stopped services |
Stop-Process | kill | Helps you stop one or more running processes |
Where-Object | ? | Enables you to select certain objects from a collection based on their property values |
Write-Output | echo | Allows you to send an object to the next command in the pipeline. If it reaches the last command in the pipeline, the command will display the objects in the console |
Don’t let the sheer amount of basic PowerShell commands intimidate you. Although we called them basic, there’s absolutely no need for you to start memorizing them. In fact, that’s the exact reason why we created the table above so that you can go on about your work without worrying about having to remember each and every command we mentioned above.
You can use it as a quick refresher or even use your browser’s search feature to locate a specific command, its alias, and what it does if you’re confused. Although we already included this piece of information in the table above, if you’re ever confused while working in PowerShell, using the help command will display a few helpful details on how you can use this program and its commands more efficiently.
You can also pair the help command with another command or alias if you want more details about that specific command. For instance, this is what PowerShell displays when you type help Add-Computer:
However, you can use help with any other of the commands or their aliases in our table above. Make sure you understand that the same command can have multiple aliases, which means that you can achieve the same result by using various aliases. Although this may sound confusing, it actually gives you plenty of flexibility in case you can’t remember one command alias, but you remember another one that can help you achieve the same goal.
Using PowerShell
Naturally, the first thing you’d want to do is locate PowerShell and launch it. One sure way to launch PowerShell from just about anywhere you are on your PC is to hold down the Shift button on your keyboard, right-click any empty spot on your screen (not a menu, icon, button, or similar object), and select Open PowerShell window here from the context menu.
In addition to giving you quick access to the PowerShell console anywhere on your PC, doing so will automatically switch the default working directory for PowerShell to the one you’re currently located at. If you’re on a Windows 10 PC, you can also launch PowerShell by pressing the Win key on your keyboard, typing PowerShell in the Start menu, and selecting PowerShell when it becomes visible in the list of results.
On older versions of Windows, you’ll need to manually locate the PowerShell executable, which you can either find in the Accessories or System folders in your Start menu. Furthermore, seeing how older systems (such as Windows 7) don’t provide you with PowerShell by default, you’ll also have to install it on your computer, along with all of its dependencies.
Notice how launching PowerShell from the Start menu will set your active working directory to C:\Users\[your username here]
. By comparison, using the Shift + Right-click method we’ve presented above will set PowerShell’s active directory to the one you’re currently at when you spawn the console. For instance, if you use Shift + right-click and open PowerShell from your desktop, you’ll notice that the active directory will be C:\Users\[your username here]\Desktop
. For obvious reasons, the [your username here]
part will be different depending on your username.
Although you can keep PowerShell for home usage just fine, it’s better if you could make use of all that it has to offer. Incidentally, these features make PowerShell awesome for corporate usage, where you need to perform a large number of operations in a short time, and most likely on a huge number of devices.
Thus, instead of running each command manually on every single machine, you could simply create an automation script in PowerShell and receive the information you need automatically, without having to physically interact with the devices in case or even be near them. Just as CMD, PowerShell can be used through command lines. However, unlike its more rudimentary counterpart (i.e. the CMD), PowerShell also lets you summon scripts and cmdlets, which makes it more powerful, but also more complicated to use.
How to use cmdlets
We’ve used the term cmdlets quite a few times in our guide, so you’re probably left wondering whatever they mean. Well, to start at the beginning, it’s worth reminding you that CMD works with commands. A cmdlet, which is pronounced command-let, is also a command, but unlike traditional CMD commands, cmdlets are specific to PowerShell and let you perform single specific operations, such as copying files, moving items from one place to another, changing the active directory, or see the contents of an item.
Sederhananya, cmdlet adalah perintah fungsi tunggal yang dapat Anda ketik langsung di baris perintah PowerShell. Jika Anda memiliki pengalaman sebelumnya dengan CMD, Anda akan menemukan PowerShell agak intuitif untuk digunakan. Satu hal yang menarik tentang PowerShell adalah ia berbagi banyak perintah dengan CMD. Oleh karena itu, menggunakan CD dengan PowerShell akan tetap mengubah direktori aktif Anda, DIR akan tetap menampilkan isi folder saat ini, dan CP akan tetap memungkinkan Anda menyalin item dari satu tempat ke tempat lain.
It’s quite worth mentioning that PowerShell is not case sensitive, unlike many other shells, which return errors if you miss using the correct case when typing your commands in them. Thus, copy-item will work just as well as Copy-Item, and if you remember neither one of them you can also use Copy, CP, and CPI (but also copy, COPY, cp, or cpi).
Most PowerShell cmdlets are written in C# and are specially built to perform operations that will return a .NET object as their result. At the time being, you could find more than a couple of hundred cmdlets you can use in PowerShell, which, let’s be fair, gives you more than just a little elbow room as far as performing operations goes.
Meskipun akan sulit untuk mengingat semua cmdlet yang mungkin harus Anda kerjakan (ingat bahwa Anda dapat menggunakan tabel di atas), ada beberapa yang akan Anda gunakan lebih sering, yang akan membuatnya sangat mudah diingat. Belum lagi fakta bahwa beberapa dari mereka cukup intuitif sehingga nama mereka benar-benar memberikan tujuan mereka (misalnya copy digunakan untuk menyalin item, memindahkan dapat digunakan untuk memindahkan file, membandingkan membantu Anda membandingkan set objek, dll).
Namun, jika Anda tidak ingin mem-bookmark artikel ini untuk digunakan nanti, Anda juga dapat mengetik cmdlet Get-Command di PowerShell, atau gcm , jika Anda ingin mempersingkatnya. Melakukannya akan menampilkan daftar lengkap perintah yang tersedia untuk Anda, dan Anda dapat menggunakan daftar itu untuk merencanakan apa pun yang Anda coba lakukan.
Membuka kunci cmdlet khusus
Pada sisi negatifnya, Microsoft tidak hanya memberi Anda akses penuh ke seluruh rangkaian cmdlet yang dapat Anda gunakan di PowerShell secara default, jadi Anda harus melewati banyak rintangan tambahan untuk membuka kunci fitur ini dan menggunakannya di komputer Anda. santai. Kabar baiknya adalah bahwa proses membuka kunci tidak memakan waktu lama, dan kemudian ada fakta bahwa itu juga dapat dilakukan melalui PowerShell, yang akan menjadi latihan yang bagus untuk Anda. Tanpa basa-basi lagi, mari kita lihat bagaimana Anda dapat membuka hak istimewa cmdlet khusus di PowerShell.
Set-ExecutionPolicy
RemoteSigned
prompt perintah PowerShell dan tekan EnterRestricted
dan konfirmasikan pilihan Anda seperti yang Anda lakukan pada langkah 7Jika Anda ingin merampingkan seluruh proses dan tidak membuang waktu mengetik semuanya di command prompt PowerShell, Anda akan senang mengetahui bahwa ada cara yang lebih sederhana untuk mencapai hasil yang sama. Luncurkan PowerShell dengan hak Administrator seperti yang Anda lakukan pada langkah pertama, dan alih-alih mengetik setiap perintah dan menunggu prompt, Anda akan menyalurkan semuanya hingga konfirmasi dengan mengetik ini:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Naturally, you will still need to confirm your choice by typing Y and hitting Enter on your keyboard, but you just skipped a step and performed a series of operations at the same time. This is exactly why advanced PowerShell users create automation scripts to perform various management operations automatically: to save time and hassle. If you want, you can use the same command above to disable custom cmdlets on your system, but you’ll have to replace RemoteSigned
with Restricted
and also confirm your choice at the end.
You can also use AllSigned
and Unrestricted
to grant yourself even more privileges when it comes to running potentially unsafe scripts on your Windows PowerShell. The AllSigned option will let you run all scripts that were created by trusted publishers, whereas the Unrestricted option will enable PowerShell to run any script, regardless of its provenience and trustworthiness. Naturally, the Unrestricted option is also the most dangerous, so try to avoid it as best as you can, if possible, especially if you are a PC novice.
See? PowerShell is already starting to look a lot more accessible than it did just a few minutes back.
How to create and use scripts in PowerShell
As we’ve mentioned before and we’re positively sure you remember, you can use PowerShell to run automation scripts. However, you can’t just yell at PowerShell “Hey you, create this script for me!” and expect it to magically work, so you’ll have to put in some elbow grease and get it done yourself. However inconvenient this may sound right now, trust us, you’ll be thankful in the long run, considering all the work you won’t need to do anymore.
Although most of us rely on specialized software such as IDEs to create scripts or programs in a specific programming language, truth be told you can use any text editor as long as it can save files to the right extension. And even if it can’t, you can just navigate to the file you created and modify its extension manually by renaming it, but let’s get back to our sheep.
If you’re interested in creating a script that can work in PowerShell, you’ll be thrilled to learn that this script you’ve probably heard a lot of, is merely a text document with an extension that makes it compatible with PowerShell, PS1. Therefore, it’s easy to see why creating these scripts can be actually handled from within virtually any text editor, as long as you save it with the right (PS1) extension.
Write-host "Please enter your name:"
$Name = read-host
"Hello $Name! Visit TipsWebTech360.com for more awesome tutorials and guides!"
Now for the actual creation part:
script.ps1
as the file nameC:\Scripts\script.ps1
.\script.ps1
If you can’t run the script and PowerShell returns an error, make sure you’ve enabled PowerShell to run custom scripts on your system, and that you’re running PowerShell as an administrator. Not doing any or both things that we’ve specified in our instructions will most likely result in an error and you won’t be able to run your script.
Remember that this is merely a basic script that is somewhat similar to the classic “Hello, world!” one. It puts a spin on it by interacting with you (i.e. asking what your name is) and letting you interact with it (i.e. typing your name which will be used to print a message for you). However, PowerShell is capable of running far more complex scripts, ranging from collecting data from an array of machines to intricate data management, advanced system configuration operations, and even creating backups of SQL databases in a blink of an eye.
How can I backup SQL databases with PowerShell?
We’re glad you asked. As we’ve mentioned countless times in our guide, there are almost endless possibilities when it comes to operations that PowerShell can help you perform. One of the most popular ones is backing up an SQL database without having to go great lengths or possess extraordinary database management capabilities. All you have to do is fire up an elevated instance of PowerShell (with Administrator privileges) and use the Backup-SqlDatabase command. However, things are a bit more complicated than that, but we’ll get to that in a few.
Backing up an SQL database isn’t as easy as simply copying files from your PC to a safe location and hope they stay safe for whenever you may need them to perform data restoration operations, but on the bright side, using PowerShell can make it look like a walk in the park. Although there are several ways to achieve this, using the command we’ve mentioned above is the fastest, simplest way to backup an SQL database.
Among the capabilities of the Backup-SqlDatabase command, it’s possible to find full database backups, database file backups, as well as transaction log backups, so you got the full package within a single command-line tool. By default, using this command will perform a full database backup, so you will need to specify if you want it to follow a certain set of rules by using the BackupFile parameter.
Note that some versions of PowerShell won’t feature this command by default, so you’ll either have to import it or install it. The good news is that installing the SQL module isn’t exactly rocket science and can be accomplished even by novices. Here’s what you’ll have to do if you can’t use the Backup-SqlDatabase command in your PowerShell session:
install-module sqlserver
import-module sqlserver
1. Complete SQL database backup
Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "Tips.WebTech360"
The command we’ve exemplified above will generate a full database backup of a database called TipsWebTech360 and save it to the default backup location of the “Computer\Instance” server instance as ‘Tips.WebTech360.bak’.
2. Perform a location-based database backup
Set-Location "SQLSERVER:\SQL\Computer\Instance"
PS SQLSERVER:\SQL\Computer\Instance> Backup-SqlDatabase -Database "Tips.WebTech360"
The first command above will change your location to the active directory within the server instance on which the backup will occur. Essentially, this technique works almost like the full database backup we’ve exemplified above, but in this example, you get to change the working directory in order to locate the server instance where the backup occurs.
This operation will also create a full backup of a database called Tips.WebTech360 and export it as an ‘Tips.WebTech360.bak’ file in the default location of the server instance you’re connected to.
3. Perform a transaction log backup
Backup-SqlDatabase -ServerInstance "Computer\Instance" -Database "Tips.WebTech360" -BackupAction Log
If you only need to backup the transaction log of a specific database, PowerShell can also help you do that through a single command you can input straight in its command-line interface. The command above will generate a backup copy of the ‘Tips.WebTech360’ database’s transaction log and export it to the default location of the ‘Computer\Instance’ server instance as a file named ‘Tips.WebTech360.trn’.
4. Create an encrypted SQL database backup
$EncryptionOption = New-SqlBackupEncryptionOption -Algorithm Aes256 -EncryptorType ServerCertificate -EncryptorName "BackupCert"
Backup-SqlDatabase -ServerInstance "." -Database "Tips.WebTech360" -BackupFile "Tips.WebTech360.bak" -CompressionOption On -EncryptionOption $EncryptionOption
If you’re worried that your database backup may fall in the wrong hands, PowerShell can also help you create ready-encrypted backup files. Naturally, you’ll have to specify some parameters such as the encryption algorithm, the encryption type (i.e. certificate), server instance, database name, backup file, and whether or not you want the output to be compressed.
The example above will create a backup of a certain ‘Tips.WebTech360’ database, encrypt it with AES-256 encryption and a server certificate, compress it, and save the resulting ‘Tips.WebTech360.bak’ file on the server instance’s default backup location. This is quite important if you plan a migration and have no surefire way to transport all backup files without risking estranging any single one of them.
5. Perform a backup on all databases in a server instance
Get-ChildItem "SQLSERVER:\SQL\Computer\Instance\Databases" | Backup-SqlDatabase
Another tool that may come in handy is PowerShell’s ability to backup all the databases on a server instance at the same time. Regardless of their number, you just fire up PowerShell, type an adaptation of the command above, and wait for the backup process to come to an end. Note that since this will backup all the databases within the server instance, you may have to wait for a while, so be patient.
The command above will back up all the databases located on the ‘Computer\Instance’ server instance and export the resulting files to the default backup location on the same server instance. The names of the backup files will be generated automatically according to each one’s corresponding database followed by the BAK extension (i.e. .bak).
Although there are several more methods to perform SQL backup with PowerShell in various ways, we’ve only presented a few that we felt were more important. Note that the commands we used in our examples above are not likely to work on your environment in their current form, so you will have to adapt them to your current situation.
For instance, you will have to change the ‘Computer\Instance’ parameter to match your own server instance and modify the name of your database to reflect the name of your own database. Remember that you can always turn to the help command in PowerShell if you ever feel that the command you’re trying to run is confusing or doesn’t work as it should.
Must-know PowerShell commands
1. Get-Help
We can’t stress this enough, but the Get-Help command should be the first one you ever learn, as it can seriously get you out of numerous sticky situations where you’re not exactly sure if you’re using the correct command, or exactly what you can achieve with the command that you’re trying to deploy.
Now that you’ve installed the sqlserver module on your system, you can try the Get-Help command now and see how Backup-SqlDatabase works. Just type Get-Help Backup-SqlDatabase in the command-line of PowerShell and brush up your PowerShell SQL database backup skills.
Note that if you just recently installed the sqlserver module on your system, the Help database may still be outdated, and you may need to run an update on it so that it can catch up on any new scripts. By default, PowerShell will detect that the content you’re trying to reach is available online, but you can’t access it locally, and even offer to update the database for you. In this case, all you need to do is type Y when prompted and hit the Enter key on your keyboard.
However, if PowerShell just prompts you with an error stating that there’s no help manual available for the command you’re interested in, you can update it manually by typing Update-Help and hitting the Enter key on your keyboard. After the update process comes to an end, you should be able to check available help documentation for the command you’re interested in.
2. Get-Process
Get-Process is paramount if you want to discover more about the system you’re currently working on. To be more specific, although you might’ve guessed what this command does already by merely looking at it, Get-Process will provide you with a list of all the processes that are currently running on the system you’re working on.
By default, Get-Process will retrieve a list of every process running on the current system you’re working on, so you may need to append some extra parameters to this command if you want more specific information and narrow the list of results. Check out in the screenshots below what you get when you run the Get-Process command by itself versus how it looks if you’re more specific and format the results.
Get-Process
Get-Process explorer | Format-List *
The second command can be customized to display additional details about any active process on your system. You can replace explorer with svchost or Chrome or any other active process on your system that you’re interested in. As we’ve mentioned above, using Get-Processes by itself can help you with that (i.e. finding a list of all running processes).
3. Stop-Process
This command is pretty much self-explanatory, as you may already have figured out that it can help you stop processes that are currently running on your system. The most common reason for doing that from PowerShell and not by using the Windows Task Manager is that sometimes processes can freeze and make GUI apps barely usable.
PowerShell users can easily identify a troublesome process using the Get-Process command we’ve previously explained, then using Stop-Process to terminate it, thus unclogging the system. Running Stop-Process by itself (without any additional parameter) in your PowerShell command-line interface will prompt you to input the ID of the process you’re trying to terminate.
However, you can also terminate a process by its name (if you know it) by appending the -Name parameter to the cmdlet, like in the example below:
Stop-Process -Name "explorer"
The command above will terminate the Explorer process, which can be useful especially if it freezes or crashes on you and refuses to load properly. Note that you’ll need to use quotes when specifying the name of the process you’re trying to terminate. If a process is stubborn and refuses to terminate (usually higher clearance processes do that), you can “convince” it by appending a -Force parameter to your command. Say, for instance, that you can’t terminate your Explorer process. In this case, you can simply type the command below:
Stop-Process -Force -Name "explorer"
Furthermore, it’s worth mentioning that using the -Force parameter in your Stop-Process command won’t ask for confirmation, as opposed to running the command without this option. If you want to find out more about this cmdlet, make sure to use the Get-Help command.
4. Get-Service
This command is among the essential command list for a good reason: it can provide you with a list of all the services that are currently installed on the system you’re working on, regardless of whether they’re running or not. As with many other cmdlets, you can customize Get-Service to provide you with more specific information, either regarding a certain service or even displaying a list of all running (or stopped) services on your machine.
You can go ahead and type Get-Service in your PowerShell command line. Doing so should provide you with a list of all the services available on your computer, as well as their display names and statuses. If you append an additional command to the original cmdlet, you can change the output, making it display only results that you’re interested in.
Get-Service "W*"
For instance, typing the command above should return a list of all services available on your computer that start with the letter ‘W’. However, you can go even further and customize your command in order to narrow the list of results even more.
Get-Service | Where-Object {$_.Status -eq “Running”}
The command above will let you see a list of all the available services on your computer that are also running at the time you’re running the cmdlet. Appending the “W*” as we did in the previous example will display a list of all the running services on your computer that start with the letter ‘W’, and the command should look like this:
Get-Service "W*" | Where-Object {$_.Status -eq "Running"}
5. Get-EventLog
Every responsible system administrator should know its way around working with event logs, seeing that these documents can provide you with useful knowledge about what happened on your system, at what time did it occur, and sometimes even what triggered that specific event.
Therefore, we can safely assume that PowerShell’s Get-EventLog command is not something you want to be missing from your toolbelt, especially if you plan on honing your system administration skills. If you know everything there is to know about event logs and their names, you can go ahead and type Get-EventLog directly in your PowerShell’s command line. Note that PowerShell will prompt you to input the name of the log you’re trying to view.
If you type the name of an empty event log (one with no entries), PowerShell will prompt you with an error and return you to the command-line interface. Therefore, it would be easier if you just used the command below, which will provide you with a list of Event Logs on your system, along with additional details about each one, such as the default overflow action, and the number of entries.
Get-EventLog -List
One of the most popular use cases for event logs is checking for errors, especially if they occurred silently, were shortly followed by a system crash, or lead to a BSOD, which we all know how cryptic can be. However, you will need to be more specific with the Get-EventLog cmdlet if you want to narrow down the list of results, which oftentimes can be huge.
Get-EventLog -LogName Security -EntryType Error
Typing the command above in your PowerShell’s command-line interface should provide you with a list of all the errors registered in your Security event log. Note that you can use the -List parameter to see all the log types in your system and replace Security
in the command above with any other log type that you find on your list, just as long as it has more than zero entries.
If you want to learn more about using the Get-EventLog command in PowerShell, feel free to use the Get-Help command we’ve talked about in the first section of this subchapter.
6. ConvertTo-HTML
Sometimes when you’re using PowerShell, you may stumble upon certain information that you want to extract and keep for future reference, create reports, or simply import it from a different application. One of the most frequently-used ways to extract this data from PowerShell and export it to an external file on your computer is the ConvertTo-HTML command.
Using this command will help you build comprehensive reports that can help you analyze extracted information and insights in a more effective manner by providing you with HTML tables that you can customize later by adding custom styles and color-coded data. As with many other PowerShell commands, ConvertTo-HTML doesn’t work by itself, and you’ll need to pair it up with an additional command which it will use as an input (or a source of data).
For instance, if you’re trying to print a report consisting of every service that starts with the letter ‘W’ and is currently running on your computer, you can type the command below:
Get-Service "W*" | Where-Object {$_.Status -eq "Running"} | ConvertTo-HTML
This will provide you with an HTML code of the data you fed to the ConvertTo-HTML function, which you can simply copy directly from the PowerShell’s command-line interface, paste it in your favorite text editor and save it as an HTML file, which you can use to view the result in any web browser.
You can use ConvertTo-HTML with virtually any PowerShell command, as long as the command you’re using as a data source will generate output. You can try it with other cmdlets, such as Get-Process, Get-EventLog, or Get-Help. Note that aside from HTML conversions, the ConvertTo cmdlet can also be used to generate JSON, CSV, and XML files. You just have to replace HTML in the command syntax with the format you’re interested in.
7. Export-CSV
If you’re working with various objects that you feel may fit way better in a table, you can use PowerShell to convert the items you’re currently handling into a series of CSV (comma-separated value) strings and export the strings to a file in one swift motion through the Export-CSV cmdlet.
As with ConvertTo-HTML, Export-CSV needs an input that it can convert to CSV strings, as it can’t just work on its own. Thus, you will need to pair it with a command that can be used to generate data, such as the Get-Service or Get-Process ones we’ve explained earlier.
Essentially, Export-CSV does almost the same thing as the ConvertTo-HTML cmdlet we’ve discussed above, aside from one important aspect that shouldn’t be overlooked: this cmdlet actually generates a file and saves it on your computer, as opposed to the ConvertTo command, which only gives you the output and lets you create the file on your own.
Let’s assume, for instance, that you’d like to turn the list of services running on your computer into a CSV file so that you can process the file further with third-party software, or put it in a spreadsheet for further reference. All you’d have to do is type the Get-Service command followed by the Export-CSV one, and mention a location where you’d like the CSV file to be generated, like in the example below:
Get-Service | Export-CSV c:\Tips.WebTech360.csv
The command above will fetch a list of all the services that are available on your computer, running or not, convert them into a series of CSV strings, and save the result as a CSV file named ‘Tips.WebTech360’ in the root of your C drive. You can then open the file in a third-party software solution, convert it into a fully-fledged table, or just store it for future usage.
PowerShell cheatsheet – CONCLUSION
Although there’s still a lot of people advocating for CMD, truth be told PowerShell is more versatile, way more powerful, but at the same time more complicated to work with than its traditional CMD counterpart. The sheer amount of features, combined with the fact that you can create automation scripts in PowerShell and perform complicated system management operations just leaves CMD in a cone of shadow.
If you’re just starting to discover PowerShell and you’re struggling to figure out what each command does, how to pipeline several commands, or how to create and run simple PowerShell scripts on your own, our guide is a great starting point. We’ve taken our time to explain some of the most important commands you should know about in PowerShell, created a few short tutorials, and also included a list of basic PowerShell commands, their aliases, and short descriptions for each item, just to simplify your PowerShell discovery journey.
Jika Anda berada di industri kesehatan atau entah bagaimana terlibat dengan TI di industri itu, kemungkinan Anda pernah mendengar tentang HIPAA. Portabilitas Asuransi Kesehatan
sFlow adalah protokol analisis aliran yang dibangun ke dalam banyak perangkat jaringan. Kami meninjau lima Kolektor dan Penganalisis sFlow Gratis Terbaik.
Untuk membantu Anda memilih yang tepat, kami memperkenalkan alat pemantauan infrastruktur tanpa agen terbaik dan memberi Anda tinjauan singkat masing-masing.
Keamanan email adalah tugas penting penyedia layanan terkelola. Sedang meninjau SolarWinds Mail Assure, salah satu alat terbaik untuk tujuan itu.
Jika Anda adalah pengguna kekuatan Windows, Anda mungkin tahu dan memahami bagaimana melakukan berbagai operasi pada PC Anda dapat memiliki lebih dari satu pendekatan dan
Latensi tampaknya menjadi musuh nomor satu jaringan. Alat pengukuran latensi ini akan mengajarkan cara menguji latensi untuk mendeteksi, menemukan, dan memperbaiki masalah.
Monitor jaringan Windows memerlukan alat dengan persyaratan terbatas. Hari ini, kami melihat alat pemantauan jaringan terbaik untuk Windows 10.
Untuk membantu Anda memilah-milah labirin alat yang tersedia untuk pemecahan masalah jaringan, kami mengungkapkan pilihan alat pemecahan masalah jaringan terbaik kami.
Untuk mencegah penyusup keluar dari sistem Anda, Anda memerlukan alat yang tepat. Baca terus selagi kami meninjau sistem deteksi intrusi (HIDS) berbasis host terbaik.
Jika Anda perlu memantau host Linux atau memantau apa pun dari platform Linux, baca terus selagi kami meninjau beberapa perangkat lunak dan alat pemantauan Linux terbaik.