Posts

Showing posts with the label Powershell

DNS IP change

  $ComputerName = get-content " $env:USERPROFILE \desktop\servers.txt" $report = @() foreach ( $Computer in $ComputerName ) {               $Networks = Get-WmiObject -Class "win32_networkadapterconfiguration" -ComputerName $Computer      }    foreach ( $Network in $Networks ) {     $IPAddress   = $Network . IpAddress [ 0 ]     $SubnetMask   = $Network . IPSubnet [ 0 ]     $DefaultGateway = $Network . DefaultIPGateway     $DNSServers   = $Network . DNSServerSearchOrder             $MACAddress   = $Network . MACAddress       $OutputObj   = New-Object -Type PSObject     $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer . ToUpper(...

Get the SSL Certs by Web Site

  $date = Get-Date $rDate = ( Get-Date -format "MM-dd-yyyy" ) $strPath = "C:\Scripts\PS1\serverinfo-$rDate.xlsx" $xl = New-Object -comobject Excel.Application $xl .Visible = $True $xl .DisplayAlerts = $False   $wb = $a .Workbooks.Add() $ws = $b .Worksheets.Item(1) $ws .Name = $rDate $ws .Cells.Item(1,1) = "Machine Name" $ws .Cells.Item(1,2) = "FriendlyName" $ws .Cells.Item(1,3) = "NotAfter" $ws .Cells.Item(1,4) = "Issuer"   $xRow = 2 $cert = dir IIS:\SslBindings | ? { $_ .Port -eq 443} | Select * foreach ( $i in $cert ) { $x = $i .thumbprint $y = get-item cert:\LocalMachine\My\ $x $FN = $y .FriendlyName $NA = $y .NotAfter $IS = $y .Issuer $ws .Cells.Item( $xRow ,1) = $comp $ws .Cells.Item( $xRow ,2) = $FN $ws .Cells.Item( $xRow ,3) = $NA $ws .Cells.Item( $xRow ,4) = $IS $xRow ++ }