Showing posts from 2017

Powershell : Certutil Find Expired Certs on CA server

Wrote this to get certificate expiration information for certificates that expired 5 days ago to ones that expire in 90 days. Wrap an invoke-command around this for remote query. $Before = (get-date).adddays(90).ToString("MM/dd/yyyy") $After = (get-date).AddDays(-5).ToString("MM/dd/yyyy") <# We create a date range with $Before, i.e. certificates expiring before this date, and $After, i.e. certificates expiring after this date. These values are converted into something that certutil can understand - $Restrict. This is then used with the certutil -restrict parameter. #> $Restrict = "NotAfter<=$Before,NotAfter>=$After" $Report = @() $cmd = & certutil.exe -view -restrict $Restrict -out "RequesterName,CommonName,Certificate Expiration Date","Certificate Template" $SplitLines = $cmd.Split("`n`r") $Index = 0 foreach ($line in $S…

Powershell: Generate CSR

Wrote this function to generate SAN certificate requests. This isn't a robust solution, nor does it follow best practice, it is more of a hey it works with a Microsoft CA.


Found a more correct script after i wrote this here

<# .Synopsis Generate CSR by Tony Unger .DESCRIPTION Generates CSR .EXAMPLE new-csr -CommonName "" -DNSNames $HostNames .EXAMPLE new-csr -CommonName "" #> function new-csr { [CmdletBinding()] [Alias()] [OutputType([int])] Param ( # Common name for request [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=0)] $CommonName, # SAN DNS names [string[]] $DNSNames …

Set non-domain windows server to use a KMS Server

REM List out KMS Servers
nslookup -type=all _vlmcs._tcp

REM Set workgroup to use a particular KMS Server
slmgr.vbs /skms <KMS server>:<port>

Powershell: Get LUN ID with Diskspace

get-wmiobject Win32_DiskDrive | select name,caption, scsibus, scsilogicalunit, @{Name="size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}} | sort-object name