What's in Your Profile - #1 - Certificates

For those of you wondering where the posts have been lately, I do apologize. I've been pretty busy at work lately and haven't had the time to come through and get a post out.

To help keep a little bit of content up here, I've thought about providing a few bits of my $profile as I tend to keep some quick handy things in there. Some are solely for my current job, so I obviously won't be posting them, but I'll try and put up some of the more generic bits on here in the hopes that it helps someone!


For my first post, I'll simply start at the beginning. The first major thing I have in my PowerShell profile is a quick region that automatically grabs and stores my self signed Code Signing Certificate for signing some of my PowerShell scripts.


#region Riston Code Signing Certificate Functions
##########################
# Find CodeSigningCerts that are installed
##########################
gci Cert:\CurrentUser\My -CodeSigningCert;
Write-Host -Foregroundcolor Green Use: Set-AuthenticodeSignature c:\foo.ps1 '$cert';

##########################
# Set $cert == Code Signing Cert
##########################
$cert = gci Cert:\CurrentUser\My -CodeSigningCert
Write-Host "USE $ cert variable to access CodeSigningCert" -ForegroundColor Cyan -BackgroundColor Black
#endregion Riston Code Signing Certificate Functions

With this now stored in $cert, I am able to now quickly call and use Set-AuthenticodeSignature

Set-AuthenticodeSignature -Certificate $cert -FilePath C:\foo.ps1 -Verbose


Comments

Popular Posts