인증서에 대한 Remove-Item

업데이트 날짜: 2014년 5월

적용 대상: Windows PowerShell 4.0

인증서 저장소, 인증서 및 개인 키를 삭제합니다.

구문

Remove-Item [-Path] <string[]> [-DeleteKey] [-Confirm] [-WhatIf] [<CommonParameters>]

설명

Cert: 드라이브에서 Remove-Item cmdlet은 인증서 및 관련 개인 키를 삭제합니다. 또한 New-Item cmdlet을 사용하여 LocalMachine 인증서 저장소 위치의 인증서 저장소를 삭제합니다. Windows PowerShell 인증서 공급자는 Windows PowerShell에 Cert: 드라이브를 추가합니다.

Windows PowerShell 3.0부터, 인증서 공급자는 Remove-Item cmdlet을 사용하여 인증서 및 개인 키를 삭제하고 LocalMachine 저장소 위치에서 사용자가 만든 인증서 저장소를 삭제할 수 있도록 하여 웹 호스팅에 대한 SSL(Secure Socket Layer) 인증서를 관리하기 위한 지원을 향상시킵니다. 그러나 CurrentUser 또는 LocalMachine과 같은 인증서 저장소 위치나 Windows에서 만드는 인증서 저장소를 삭제하는 데는 이 기능을 사용할 수 없습니다.

참고: Cert: 드라이브에서는 Remove-Item의 DeleteKey, Path, WhatIf 및 Confirm 매개 변수만 유효합니다. 다른 모든 매개 변수 및 매개 변수 값은 무시됩니다.

매개 변수

-DeleteKey

인증서를 삭제할 때 연결된 개인 키도 삭제합니다.

원격 컴퓨터의 Cert:\CurrentUser 저장소 위치에서 사용자 인증서와 연결된 개인 키를 삭제하려면 위임된 자격 증명을 사용해야 합니다. Invoke-Command cmdlet을 사용하여 Remove-Item 명령을 원격으로 실행할 경우 보안 위험을 고려한 후 CredSSP 매개 변수를 사용하여 위임을 사용하도록 설정합니다. 이 매개 변수는 인증서 공급자의 모든 하위 디렉터리에 사용할 수 있지만 인증서에만 적용됩니다.

이 매개 변수는 Windows PowerShell 3.0에서 도입되었습니다.

필수 여부

false

위치

명명됨

기본값

False

파이프라인 입력 적용 여부

false

와일드카드 문자 허용 여부

false

-Path <string[]>

삭제할 인증서 및 인증서 저장소의 경로를 지정합니다. 와일드카드가 지원됩니다. 매개 변수 이름("-Path")은 선택 사항입니다.

필수 여부

true

위치

1

기본값

파이프라인 입력 적용 여부

true (ByValue, ByPropertyName)

와일드카드 문자 허용 여부

false

-Confirm

명령을 실행하기 전에 확인을 요청하는 메시지가 표시됩니다.

필수 여부

false

위치

명명됨

기본값

파이프라인 입력 적용 여부

false

와일드카드 문자 허용 여부

false

-WhatIf

명령을 실제로 실행하지 않으면서 명령을 실행할 경우 어떻게 되는지 설명해 보세요.

필수 여부

false

위치

명명됨

기본값

파이프라인 입력 적용 여부

false

와일드카드 문자 허용 여부

false

<CommonParameters>

이 cmdlet은 일반 매개 변수 -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, -OutVariable, -Verbose, -WarningAction 및 -WarningVariable을 지원합니다. 자세한 내용은 about_CommonParameters를 참조하세요.

입력 및 출력

입력 유형은 cmdlet에 파이프할 수 있는 개체의 유형입니다. 반환 유형은 cmdlet에서 반환되는 개체의 유형입니다.

입력

System.String

Cert: 드라이브의 Remove-Item cmdlet으로 경로를 파이프할 수 있습니다.

출력

없음

이 cmdlet은 어떠한 출력도 생성하지 않습니다.

참고

-- Windows PowerShell 3.0부터 Cert: 드라이브를 포함하는 Microsoft.PowerShell.Security 모듈을 모든 세션으로 자동으로 가져올 수 없습니다. Cert: 드라이브를 사용하려면 Import-Module cmdlet을 사용하여 모듈을 가져오거나 Cert: 드라이브를 사용하는 명령(예: "Set-Location Cert:")을 실행합니다.

예제 1

C:\PS>Remove-Item -Path cert:\LocalMachine\CA\5DDC44652E62BF9AA1116DC41DE44AB47C87BDD0

Description
-----------
This command deletes a certificate from the CA certificate store, but leaves the associated private key intact.





예제 2

C:\PS># Delete a certificate and private key on a remote computer

Description
-----------
This series of commands enables delegation and then deletes the certificate and associated private key on a remote computer. To delete a private key on a remote computer, you must use delegated credentials. 

The first command uses the Enable-WSManCredSSP cmdlet to enable Credential Security Service Provider (CredSSP) authentication on a client on the S1 remote computer. CredSSP permits delegated authentication.

PS C:\>Enable-WSManCredSSP -Role Client -DelegateComputer S1 


The second command uses the Connect-WSMan cmdlet to connect the S1 computer to the WinRM service on the local computer. When this command completes, the S1 computer appears in the local WSMan: drive in Windows PowerShell.

PS C:\>Connect-WSMan -ComputerName S1 -Credential Domain01\Admin01


The third command uses the Set-Item cmdlet in the WSMan: drive to enable the CredSSP attribute for the WinRM service.

PS C:\>Set-Item -Path WSMan:\S1\Service\Auth\CredSSP -Value $true


The fourth command uses the New-PSSession cmdlet to start a remote session on the S1 computer with CredSSP authentication. It saves the session in the $s variable.

PS C:\> $s  = New-PSSession S1 -Authentication CredSSP -Credential Domain01\Admin01


The fifth command uses the Invoke-Command cmdlet to run a Remove-Item command in the session in the $s variable. The Remove-Item command uses the DeleteKey parameter to remove the private key along with the specified certificate. 

PS C:\> Invoke-Command -Session $s { Remove-Item cert:\LocalMachine\My\D2D38EBA60CAA1C12055A2E1C83B15AD450110C2 -DeleteKey  }





예제 3

C:\PS>Get-ChildItem -Path cert:\LocalMachine\WebHosting -ExpiringInDays 0 | Remove-Item -DeleteKey

Description
-----------
This command uses the ExpiringInDays parameter of the Get-ChildItem cmdlet with a value of 0 to get certificates in the WebHosting store that have expired.

It uses a pipeline operator to pass the certificates to the Remove-Item cmdlet, which deletes them. The command uses the DeleteKey parameter to delete the private key along with the certificate.





예제 4

C:\PS>Get-ChildItem -Path cert:\LocalMachine -DnsName *Fabrikam* | Remove-Item

Description
-----------
This command deletes all certificates that have a DNS name that contains "Fabrikam". It uses the DNSName parameter of the Get-ChildItem cmdlet to get the certificates and the Remove-Item cmdlet to delete them.





See Also

Concepts

인증서 공급자

Other Resources

Get-ChildItem
Get-Item
Get-PfxCertificate
Get-PSDrive
Move-Item
New-Item