Posts

Showing posts from April, 2021

Powershell AD group

To list the AD groups users detail. $nameofgroup= 'groupname' $groupsusers=Get-ADGroup -Identity $nameofgroup |    ForEach-Object{                 $settings=@{Group=$_.DistinguishedName;Member=$null}         $_ | Get-ADGroupMember |               ForEach-Object{                                        $settings.Member=$_.Name                     New-Object PsObject -Property $settings                 }    }     $groupsusers | Export-Csv $env:USERPROFILE\desktop\GroupsUsers.csv –NoTypeInformation --- Import-Module ActiveDirectory $Groups = (Get-AdGroup -filter * | Where {$_.name -like "**"} | select name -ExpandProperty name) $Table = @() $Record = @{   "Group Name" = ""   "Name" = ""   "Username" = ""} Foreach ($Group in $Groups) {   $Arrayofmembers = Get-ADGroupMember -identity $Group -recursive | select name,samaccountname   foreach ($Member in $Arrayofmembers) {     $Record."Group Name" = $Group  

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 ++ }