Sunday, November 12, 2017

How to get list of empty groups in active directory

     When we do cleanup activity in Ad,we might wanted to check if any empty groups exist's.How to get the list of empty groups in Ad ?

We can get the list easily with help of Active  directory power shell .Below is the one-liner command to pull the information

Get-ADGroup -Filter * -Properties Members | where {-not $_.members} | select Name | Export-Csv C:\ADemptygroupLIST.csv –NoTypeInformation

Regards
Bijesh
Blog4IT

Wednesday, November 8, 2017

Command To Get the list of Active directory users with account expire date

DSQUERY Command To Get the list of  Active directory users with account expire date

dsquery user -name * -limit 0 | dsget user -samid -acctexpires


Regards
Bijesh

Command to add DNS record

Simple Command to Add add DNS record

Dnscmd  ServerName /recordadd  <DomainName> HostEntry A <x.x.x.x>

Regards
Bijesh

Veeam Powershell command to get the list of job completed with status Success

Veeam Powershell command to get the list of job completed with status Success

Get-VBRJob | Where-Object {$_.GetLastResult() -ne "Failed" -and $_.GetLastResult() -ne "None" -and $_.findlastsession().progress.stoptime -ge (Get-Date).addhours(-24)} |Select-object  @{Name="Job";Expression={$_.Name}}, @{Name="Status";Expression={$_.GetLastResult()}}, @{Name="ID";Expression={$_.id}}, @{Name="Job Msg";Expression={$_.FindLastSession().info.description}}, @{Name="Session";Expression={$_.FindLastSession()}} | Select-Object "Job","Status","ID"

Regards
Bijesh

Veeam Powershell command to get the list of job completed with status Failed/Warning

Veeam Powershell command to get the list of job completed with status Failed/Warning

 Get-VBRJob | Where-Object {$_.GetLastResult() -ne "Success" -and $_.GetLastResult() -ne "None" -and $_.findlastsession().progress.stoptime -ge (Get-Date).addhours(-24)} |Select-object  @{Name="Job";Expression={$_.Name}}, @{Name="Status";Expression={$_.GetLastResult()}}, @{Name="ID";Expression={$_.id}}, @{Name="Job Msg";Expression={$_.FindLastSession().info.description}}, @{Name="Session";Expression={$_.FindLastSession()}} | Select-Object  "Job","Status","ID"


Regards
Bijesh

Tuesday, November 7, 2017

Power shell command to get last windows update install date

Powershell command to get last windows update install date


Get-hotfix -ComputerName <Servername> | select-Object Source,installedon -first 1


Regards
Bijesh

Horizon View Powercli command to Get number of unassigned VM’s Count in pool

Horizon View  Powercli command to Get number of unassigned VM’s Count in a pool


Get-Pool | Select Pool_id, @{Name="Unassigned VMs";Expression={($_ | Get-DesktopVM | ? {$_.user_displayname -eq "$null"}).Count}}

Regards
Bijesh

Power shell Command to export mailbox to PST

Power Shell command –To export mailbox to PST


  New-MailboxExportRequest –Mailbox  <Username>  –FilePath \\<servername>\Sharename\user.pst


    PS:          -FilePath parameter only accepts a UNC path (\\servername\share).

Regards
Bijesh

Monday, November 6, 2017

Powershell Command to Access New-PSSession for remote exchange server


Access New-PSSession for remote exchange server



$exg = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<server fqdn>/PowerShell/ -Authentication Kerberos

Import-PSSession $exg


Regards
Bijesh

Command to get Power shell session History

Simple command to get PS Session History



How to save power shell session input and output to a file


Sometime while working on powershell we may want to save the ran command and output to a file .How do we save the session input and output to a file ?



To Start saving the transcript,

    start-transcript -Path <FileName>

To Stop saving the transcript

    stop-transcript




Regards
Bijesh