<#
#################################################################################
## Author: BRIAN HUNTER
## Date: 8/10/2020
## Email: brian@sutechy.com
#################################################################################
PS> Install-Module -Name CredentialManager -RequiredVersion 2.0
WARNING: Version '2.0' of module 'CredentialManager' is already installed at 'C:\Program
Files\WindowsPowerShell\Modules\CredentialManager\2.0'. To reinstall this version '2.0', run Install-Module or
Updated-Module cmdlet with the -Force parameter.
PS> New-StoredCredential -Target hch-tp69 -Username ttest -Password tt@hch123
PS> Get-Command -Module CredentialManager
#>
if(-not(get-module credentialmanager)){Install-Module -Name CredentialManager -RequiredVersion 2.0 }
Import-Module CredentialManager
$User = Read-Host -Prompt 'Input the user name: '
$Date = Get-Date
$b = get-aduser -identity $User -properties passwordlastset
$b
$x = Get-Storedcredential -AsCredentialObject
if(! $x) {
Write-Host "`nALERT: No Credentials to Remove`n"
Exit(1)
}
if($x) { Write-Host "`n==================================================`n`nALERT: Removing Credentials at $DATE`n==================================================" ; $x }
foreach($cred in Get-StoredCredential -AsCredentialObject){
Remove-StoredCredential -Target $cred.TargetName -Type $cred.Type
}
Exit(0)