네트워크에 대해 자세히 알려주는 10가지 최고의 핑 스윕 도구
핑 스윕은 여러 가지 방법으로 유용하게 사용될 수 있습니다. 찾을 수 있는 10가지 최고의 Ping 스윕 도구에 대해 논의하고 소개하는 동안 계속 읽으십시오.
Windows 고급 사용자라면 PC에서 다양한 작업을 수행하는 방법이 한 가지 이상의 접근 방식을 가질 수 있다는 것과 특수 GUI 앱이 명령을 입력하는 것보다 종종 더 제한적이라는 사실을 알고 이해하고 있을 것입니다. 수동으로 명령줄. 그 텍스트의 벽이 눈앞에 펼쳐지는 것을 볼 때 그 만족감이 있고, 그 결과가 오류가 아니라면 더 가치가 있습니다.
Windows PC에서는 CMD 또는 PowerShell을 통해 이를 달성할 수 있는 두 가지 방법만 있습니다. CMD는 PowerShell보다 조금 더 유명하지만 CMD를 통해 실행할 수 있는 작업을 포함하여 훨씬 더 많은 작업을 수행할 수 있다는 점을 고려하면 덜 강력합니다. PowerShell은 이전 CMD의 강력함과 스크립팅 및 cmdlet 기능을 결합하여 수행할 수 있는 작업과 관련하여 많은 가능성을 제공한다고 말할 수 있습니다.
그러나 PowerShell을 사용하여 수행할 수 있는 가능한 작업의 수는 이전에 CMD(PowerShell은 물론)에 대해 들어본 적이 없는 사용자는 말할 것도 없고 노련한 사용자에게도 상당히 위협적일 수 있습니다. 하지만 걱정하지 마세요. PowerShell로 해낼 수 있고 장기적으로 암기할 수도 있는 몇 가지 쉬운 트릭을 시도하고 가르쳐 드리겠습니다. 이 "집중 과정"은 PowerShell에 대한 포괄적인 설명서 역할을 하지는 않지만 몇 가지 지침을 제공하고 여러 명령을 설명하여 PowerShell을 찾는 데 도움이 되기를 바랍니다. 준비가 되었다면 시작하겠습니다.
파워쉘이란?
위에서 간단히 언급했듯이 PowerShell은 광범위한 작업에 사용할 수 있는 강력한 도구입니다. 그 외에도 PowerShell은 명령줄 셸(예: CMD), 스크립팅 언어 및 구성 관리 프레임워크를 포함하되 이에 국한되지 않는 여러 강력한 도구로 구성된 작업 자동화 솔루션입니다.
텍스트만 수락하고 반환할 수 있는 다른 셸과 달리 PowerShell은 포함하는 뛰어난 기능 덕분에 .NET 개체도 수락하고 반환할 수 있습니다. PowerShell의 가장 중요한 셸 관련 기능은 다음과 같습니다.
그러나 이는 빙산의 일각에 불과합니다. 앞에서 언급했듯이 PowerShell은 단순한 셸 이상입니다. 시스템 관리 작업을 자동화하기 위한 강력한 스크립팅 언어로 사용할 수 있을 뿐만 아니라 다양한 환경에서 솔루션을 구축, 분석, 테스트 및 배포하려는 경우에도 사용할 수 있습니다.
PowerShell이 .NET CLR(.NET Common Language Runtime)을 기반으로 한다는 점을 감안할 때 PowerShell이 작동하는 모든 입력 및 출력이 .NET 개체인 이유를 쉽게 알 수 있습니다. 또한 PowerShell이 정보를 추출할 수 있도록 텍스트 출력을 구문 분석할 필요가 전혀 없습니다. PowerShell의 스크립팅 기능 중 다음을 찾을 수 있습니다.
코드를 통해 엔터프라이즈 인프라를 관리하고 구성하는 데 더 관심이 있다면 PowerShell이 DSC(Desired State Configuration) 관리 프레임워크를 통해 이러한 가능성도 제공한다는 사실을 알게 되어 기쁩니다. PowerShell의 DSC를 사용하여 쉽게 수행할 수 있는 작업 중에서 다음을 상기시켜 드립니다.
PowerShell에는 Perl과 다소 유사한 독점 프로그래밍 언어와 함께 제공되는 독점 명령줄이 있습니다. 처음에 PowerShell은 사용자가 자신의 컴퓨터에서 개체를 관리하는 데 도움을 주기 위해 개발되었지만, 짐작할 수 있듯이 많은 발전을 이뤘고 이제는 더 광범위하고 복잡한 작업에 사용됩니다.
예를 들어 PowerShell의 광범위한 작업 환경을 활용하여 다양한 시스템 관리 작업을 수행할 뿐만 아니라 자동화할 수 있으므로 매번 지루하고 반복적인 작업을 수행할 필요가 없습니다. 또한 다음을 포함하되 이에 국한되지 않는 하나의 프로그램(예: PowerShell)을 통해 과다한 리소스에 액세스할 수 있다는 점을 언급하는 것도 매우 중요합니다.
오늘날 PowerShell의 가장 인기 있는 목적 중 하나는 최종 사용자가 시스템 관리 작업을 자동화하여 지루하고 반복적인 일련의 작업에 참여하지 않도록 돕는 것입니다. 반복적인 작업에서 인적 요소를 제거하면 여러 가지 이유로 효율성을 높이고 인적 오류를 줄이는 것으로 입증되었으므로 실제로 모두에게 윈-윈입니다.
PowerShell을 사용하여 간단하거나 더 복잡한 명령을 실행할 수 있지만 이 프로그램은 PowerShell에 의해 자동으로 실행되는 해당 명령을 기반으로 스크립트를 만드는 데도 도움이 될 수 있습니다. 또한 사용자 지정하고 나중에 실행할 수 있는 cmdlet이라는 명령이 엄청나게 많습니다.
PowerShell은 플랫폼 간 및 오픈 소스입니다. 즉, Wine 또는 Boot Camp와 같은 트릭 및 호환성 향상 도구에 의존하지 않고도 기본적으로 Mac 또는 Linux와 같은 다른 시스템에서도 사용할 수 있습니다.
기본 PowerShell 명령 목록
PowerShell이 컴퓨터의 또 다른 명령 프롬프트 이상이며 실제로 CMD 기능뿐만 아니라 특정 프로그래밍 언어와 자동화에 사용할 수 있는 다양한 스크립트도 포함한다는 사실을 알게 되었기 때문에 PowerShell이 약간 위협적으로 느껴질 수 있음을 이해합니다. 시스템 관리 작업.
그러나 PowerShell과 PowerShell이 제공하는 모든 것을 마스터하기로 결정했다면 가장 기본적인 기능부터 시작하는 것이 좋습니다. 그렇게 하면 실수로 잘못된 기능을 사용하고 그동안 수행한 모든 작업이 더 먼 기억처럼 보이기 시작했을 때 진행 상황을 몇 개월 뒤로 되돌릴 필요가 없습니다.
이것이 바로 이 강력한 프로그램의 기능을 테스트하고 정확히 어떤 기능을 수행하는지 확인하기 위해 PowerShell 세션 내에서 안전하게 사용할 수 있는 기본 명령 목록을 준비한 이유입니다. 아래 목록은 명령 이름, 별칭 및 각 명령이 수행하는 작업에 대한 간략한 설명으로 구성됩니다.
명령 이름이나 별칭을 사용할 수 있으며 결과는 정확히 동일합니다. 별칭 사용을 선호하는 이유는 별칭을 사용하는 것이 훨씬 빠르기 때문입니다. 별칭을 올바르게 기억하고 해당 명령 이름과 연결할 수 있다면 작업을 신속하게 완료하려는 경우 더 합리적입니다.
명령 이름 | 별명 | 설명 |
---|---|---|
콘텐츠 추가 | 교류 | 파일에 내용(예: 단어 또는 데이터)을 추가할 수 있습니다. |
추가-PSSnapIn | asnp | 현재 세션 에 여러 Windows PowerShell 스냅인을 추가하는 데 도움이 됩니다. |
명확한 내용 | 씨엘씨 | 실제 항목을 삭제하지 않고 항목의 내용을 지웁니다. |
클리어 히스토리 | 청순 | 명령 기록에서 모든 항목을 지웁니다. |
클리어 호스트 | 분명한 | 호스트 프로그램의 표시를 지웁니다. |
클리어 호스트 | 클스 | clear 와 같은 역할을 합니다. |
클리어 아이템 | 클리 | 실제 항목을 삭제하지 않고 항목의 내용을 제거합니다. |
항목 속성 지우기 | 클프 | 속성 자체를 실제로 삭제하지 않고 속성 값을 지웁니다. |
변수 지우기 | clv | 변수의 값을 삭제합니다 |
비교 객체 | 비교하다 | 두 개체 집합을 비교할 수 있습니다. |
비교 객체 | 차이 | 비교 와 동일한 작업을 수행합니다. |
Connect-PSSession | CNN | 연결을 끊은 세션에 다시 연결할 수 있습니다. |
변환 경로 | 이력서 | Windows PowerShell 경로를 Windows PowerShell 공급자 경로 로 변환할 수 있습니다. |
복사 항목 | 복사 | 특정 위치에서 다른 위치로 항목을 복사하는 데 도움이 됩니다. |
복사 항목 | cp | 복사 와 동일한 작업을 수행합니다. |
복사 항목 | cpi | 복사 및 cp 와 동일한 작업을 수행합니다. |
항목 속성 복사 | cpp | 주어진 위치에서 다른 위치로 값과 속성을 복사할 수 있습니다. |
비활성화-PSBreakpoint | DBP | 현재 콘솔에서 중단점을 비활성화하는 데 도움이 됩니다. |
연결 끊기-PSSession | DNS | 현재 세션에서 연결을 끊습니다. |
Enable-PSBreakpoint | ebp | 현재 콘솔에서 중단점을 활성화할 수 있습니다. |
Enter-PSSession | etsn | 원격 장치와의 대화형 세션을 시작하는 데 도움이 됩니다. |
Exit-PSSession | exsn | 원격 장치와의 대화형 세션 종료 |
내보내기 별칭 | 에팔 | 현재 정의된 별칭에 대한 정보를 출력 파일 로 내보낼 수 있습니다. |
내보내기-Csv | epcsv | 개체를 여러 쉼표로 구분된(CSV) 문자열 로 변환 하고 문자열을 CSV 문서로 내보낼 수 있습니다. |
내보내기-PSSession | EPSN | 다른 세션에서 명령을 가져와 Windows PowerShell 모듈로 내보냅니다. |
ForEach-객체 | % | 입력 개체 컬렉션에 포함 된 각 항목에 대해 특정 작업을 수행 합니다. |
ForEach-객체 | 각각 | % 와 동일한 작업을 수행합니다. |
형식-사용자 정의 | FC | 출력 형식을 지정하기 위해 사용자 정의된 보기를 사용하는 데 도움이 됩니다. |
형식 목록 | 플로리다 | 각 속성 이 새 줄에 배치 되는 속성 목록으로 출력 형식을 지정할 수 있습니다. |
형식-표 | 피트 | 출력 형식을 테이블로 지정할 수 있습니다. |
형식 전체 | fw | 각 개체의 속성 하나만 표시 되는 넓은 테이블로 개체의 서식을 지정하는 데 도움 이 됩니다. |
별칭 가져오기 | 여자 | 현재 세션의 별칭을 가져옵니다. |
Get-Child 항목 | 디렉토리 | 파일 시스템 드라이브의 모든 파일 및 폴더 목록을 가져옵니다. |
Get-Child 항목 | gci | dir 과 같은 작업을 수행합니다. |
Get-Child 항목 | 엘 | dir 및 gci 와 동일한 작업을 수행합니다. |
명령 받기 | gcm | 사용할 수 있는 모든 명령 목록을 가져옵니다. |
콘텐츠 가져오기 | 고양이 | 파일의 내용을 표시합니다 |
콘텐츠 가져오기 | GC | 고양이 와 같은 일을 한다 |
기록 가져오기 | 가이 | 현재 세션 동안 입력한 모든 명령 목록을 가져옵니다. |
기록 가져오기 | 시간 | ghy 와 같은 일을 합니다. |
기록 가져오기 | 역사 | ghy 및 h 와 동일한 작업을 수행합니다. |
아이템 가져오기 | 미군 병사 | 파일 및 폴더를 가져올 수 있습니다. |
항목 속성 가져오기 | GP | 지정한 항목의 속성을 가져옵니다. |
취직 | gjb | 현재 세션에서 실행 중인 모든 Windows PowerShell 백그라운드 작업 목록을 검색합니다. |
위치 가져오기 | 글 | 현재 위치 스택 또는 작업 위치에 대한 정보를 가져옵니다. |
위치 가져오기 | 암호 | gl 과 동일한 작업을 수행합니다. |
회원가입 | GM | 지정된 개체의 모든 속성과 메서드를 가져옵니다. |
모듈 가져오기 | GMO | 현재 세션 으로 가져올 수 있는 가져온 모듈 또는 모듈 목록을 검색합니다. |
프로세스 가져오기 | GPS | 로컬 또는 원격 컴퓨터 에서 실행 중인 모든 프로세스의 목록을 가져옵니다. |
프로세스 가져오기 | 추신 | gps 와 같은 기능을 합니다. |
Get-PSBreakpoint | gbp | 현재 세션에 설정된 모든 중단점을 검색합니다. |
Get-PSCallStack | GCS | 현재 호출 스택을 표시합니다. |
Get-PSDrive | gdr | 현재 세션에서 드라이브를 가져옵니다. |
Get-PSSession | gsn | 로컬 및 원격 Windows PowerShell 세션 목록을 검색합니다. |
Get-PSSnapIn | gsnp | 컴퓨터의 모든 Windows PowerShell 스냅인 목록을 가져옵니다. |
서비스 받기 | GSV | 로컬 또는 원격 컴퓨터의 모든 서비스를 나열합니다. |
고유해지기 | 구 | 정렬된 목록에서 고유한 항목 검색 |
변수 가져오기 | gv | 현재 콘솔의 모든 변수 목록을 표시합니다. |
Get-WmiObject | 구미 | WMI(Windows Management Instrumentation) 클래스 인스턴스 또는 사용 가능한 클래스에 대한 정보를 가져옵니다. |
그룹 개체 | 그룹 | 지정한 속성에 대해 동일한 값을 포함하는 개체를 그룹화할 수 있습니다. |
돕다 | 남성 | Windows PowerShell 명령 및 개념 에 대한 자세한 내용을 표시합니다. |
가져오기 별칭 | 아이팔 | 파일에서 별칭 목록을 가져올 수 있습니다. |
가져오기-Csv | ipcsv | CSV 파일에 포함된 모든 항목을 사용하여 테이블과 같은 사용자 정의 개체 구축 |
가져오기 모듈 | 입모 | 현재 세션으로 모듈 가져오기 |
Import-PSSes sion | ipsn | 다른 세션의 명령을 현재 세션으로 가져옵니다. |
명령 호출 | ICM | 로컬 및 원격 컴퓨터에서 명령을 실행할 수 있습니다. |
호출 표현식 | 아이엑스 | 로컬 컴퓨터에서 명령 또는 표현식을 실행할 수 있습니다. |
호출 기록 | 아이고 | 세션 기록에서 명령을 실행합니다. |
호출 기록 | 아르 자형 | ihy 와 같은 작업을 수행합니다. |
호출 항목 | ii | 지정된 항목에 대해 기본 작업을 수행합니다. |
Invoke-RestMethod | irm | RESTful 웹 서비스에 HTTP 또는 HTTPS 요청을 보냅니다. |
호출-WebRequest | 곱슬 곱슬하다 | 인터넷의 웹 페이지에서 콘텐츠 검색 |
호출-WebRequest | iwr | 컬 과 같은 역할을 합니다. |
Invoke-WMI 메서드 | iwmi | WMI(Windows Management Instrumentation) 메서드 를 호출할 수 있습니다. |
측정 대상 | 측정하다 | 문자열 개체의 단어, 줄 및 문자 뿐만 아니라 개체의 숫자 속성을 결정 합니다. |
mkdir | MD | 새 항목(디렉토리)을 만듭니다. |
아이템 이동 | 미 | 특정 위치에서 다른 위치로 항목을 이동할 수 있습니다. |
아이템 이동 | 이동하다 | 같은 일이 있습니까 마일 |
아이템 이동 | 뮤직비디오 | mi 와 move 와 같은 일을 한다. |
Move-ItemProperty | MP | 특정 위치에서 다른 위치로 속성을 이동할 수 있습니다. |
새 별칭 | 날 | 새 별칭을 만들 수 있습니다. |
새로운 물품 | 니 | 새 항목을 만들 수 있습니다. |
새로운 모듈 | nmo | 메모리에만 존재하는 새로운 동적 모듈 생성 |
New-PSDrive | 산 | 임시 및 영구 매핑된 네트워크 드라이브를 만들 수 있습니다. |
New-PSDrive | ndr | 마운트 와 동일한 작업을 수행합니다. |
New-PSSession | nsn | 로컬 또는 원격 컴퓨터에 대한 영구 연결을 설정합니다. |
New-PSSessionConfigurationFile | npssc | 세션 구성 파일을 생성합니다. |
새 변수 | 네바다 | 새로운 변수를 생성할 수 있습니다. |
아웃 그리드 뷰 | ogv | 별도의 창에서 대화형 테이블로 출력을 보낼 수 있습니다. |
외부 호스트 | 오 | 출력을 명령줄(CMD)로 보냅니다. |
출력 프린터 | lp | 출력을 프린터로 보낼 수 있습니다. |
팝 위치 | 팝 | Modifies your current location to the location that was pushed to the stack most recently. You can use the Push-Locationcmdlet (pushd) to pop the location either its default stack or from a stack that you create. |
powershell_ise.exe | ise | Displays an explanation on how you can use the PowerShell_ISE.exe command-line tool |
Push-Location | pushd | Appends the current location to the top of a location stack |
Receive-Job | rcjb | Fetches the results of current session Windows PowerShell background jobs |
Receive-PSSession | rcsn | Retrieves results of commands from disconnected sessions |
Remove-Item | del | Removes files and folders |
Remove-Item | erase | Does the same thing as del |
Remove-Item | rd | Does the same thing as del and erase |
Remove-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.
Simply put, cmdlets are single function commands that you can type directly in PowerShell’s command line. If you have any prior experience with the CMD, you’ll find PowerShell somewhat intuitive to work with. One interesting thing about PowerShell is that it shares plenty of commands with CMD. Therefore, using CD with PowerShell will still change your active directory, DIR will still display the contents of the current folder, and CP will still let you copy an item from one place to another.
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.
Although it will be difficult to remember all the cmdlets you may have to work with (remember that you can use the table above), there are a few that you’ll use more frequently, which will make them incredibly easy to remember. Not to mention the fact that some of them are intuitive enough that their name actually gives away their purpose (e.g. copy is used to copy items, move can be used to move files, compare helps you compare sets of objects, etc).
However, if you’re not exactly in the mood to bookmark this article to use it later, you could also type in the Get-Command cmdlet in PowerShell, or gcm, if you want to keep things short. Doing so will display a full list of commands that are available to you, and you can use that list to plan ahead on whatever it is you’re trying to do.
Unlocking custom cmdlets
On the downside, Microsoft doesn’t just give you full access to the whole array of cmdlets that you can use in PowerShell by default, so you’ll have to jump through a bunch of extra hoops to unlock this feature and use it at your leisure. The good news is that the unlocking process doesn’t take long, and then there’s the fact that it can also be done through the PowerShell, which will make great practice for you. Without any further ado, let’s see how you can unlock custom cmdlets privileges in PowerShell.
Set-ExecutionPolicy
RemoteSigned
in the PowerShell command prompt and press EnterRestricted
and confirm your choice as you did at step 7If you want to streamline the whole process and not waste time typing everything down in PowerShell’s command prompt, you’ll be glad to learn that there’s an even simpler way to achieve the same result. Launch PowerShell with Administrator rights as you did at step one, and instead of typing each command and waiting for the prompt, you’re gonna pipeline everything up until the confirmation by typing this:
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.
PowerShell을 막 발견하기 시작했고 각 명령이 하는 일, 여러 명령을 파이프라인하는 방법 또는 간단한 PowerShell 스크립트를 직접 만들고 실행하는 방법을 파악하는 데 어려움을 겪고 있다면 이 가이드가 훌륭한 출발점이 될 것입니다. 시간을 내어 PowerShell에서 알아야 할 가장 중요한 몇 가지 명령을 설명하고 몇 가지 짧은 자습서를 만들었으며 기본 PowerShell 명령 목록, 해당 별칭 및 각 항목에 대한 간단한 설명도 포함했습니다. PowerShell 발견 여정.
핑 스윕은 여러 가지 방법으로 유용하게 사용될 수 있습니다. 찾을 수 있는 10가지 최고의 Ping 스윕 도구에 대해 논의하고 소개하는 동안 계속 읽으십시오.
웹 사이트는 중요하며 적절한 성능을 위해 지속적으로 면밀히 모니터링해야 합니다. 다음은 웹사이트 모니터링을 위한 최고의 도구입니다.
네트워크 관리 소프트웨어 시장은 매우 혼잡합니다. 최고의 네트워크 관리 도구에 대한 권장 사항을 따라 검색을 단축하십시오.
여러 머신을 관리하는 수고를 덜 수 있는 최고의 소프트웨어 배포 도구를 살펴보겠습니다.
sFlow는 수많은 네트워킹 장치에 내장된 흐름 분석 프로토콜입니다. 최고의 무료 sFlow 수집기 및 분석기 상위 5개를 검토합니다.
올바른 도구를 선택하는 데 도움이 되도록 최고의 에이전트 없는 인프라 모니터링 도구를 소개하고 각 도구에 대한 빠른 검토를 제공했습니다.
데이터 센터에서 Linux가 점점 더 대중화됨에 따라 Linux에서 대역폭 모니터링을 살펴보고 최고의 도구도 검토하고 있습니다.
이메일 보안은 관리형 서비스 제공업체의 중요한 작업입니다. 그 목적을 위한 최고의 도구 중 하나인 SolarWinds Mail Assure를 검토하고 있었습니다.
대기 시간은 네트워크의 가장 큰 적인 것 같습니다. 이러한 대기 시간 측정 도구는 대기 시간을 테스트하여 문제를 감지하고 찾고 수정하는 방법을 알려줍니다.
Windows 네트워크 모니터에는 요구 사항이 제한된 도구가 필요합니다. 오늘은 Windows 10을 위한 최고의 네트워크 모니터링 도구를 살펴보았습니다.