Monday, October 12, 2015

Folder ACL

This script will fetch ACL details for folders and sub folders

Get-childitem "Complete Path of  Parent folder" -recurse | where{$_.psiscontainer} |
Get-Acl | % {
$path = $_.Path
$_.Access | % {
New-Object PSObject -Property @{
Folder = $path.Replace("Microsoft.PowerShell.Core\FileSystem::","")
Access = $_.FileSystemRights
Control = $_.AccessControlType
User = $_.IdentityReference
Inheritance = $_.IsInherited
}
}
} | export-csv C:\temp\ACL.csv –force

Fetch host name from Ip address


This script will fetch the host name form IP address for a list of servers.

$listofIPs = Get-Content "c:\Ip.txt"

#Location of the file which contains the list of IP addresses
$ResultList = @()
foreach ($ip in $listofIPs)
{     
      $result = $null     
      $currentEAP = $ErrorActionPreference     
      $ErrorActionPreference = "silentlycontinue"     
      $result = [System.Net.Dns]::GetHostbyAddress("$ip") 
      $ErrorActionPreference = $currentEAP     
      If ($Result)
      {          
           $Resultlist += $IP + "," + [string]$Result.HostName     
      } 
      Else    
      {         
           $Resultlist += $IP + " , No HostNameFound"     
      }

}$Resultlist | Out-File "c:\output.txt"

Friday, September 25, 2015

List the User Logged on to a Remote Computer

Script to list the User Logged on to a Remote Computer


strComputer = "abc"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 

Set colComputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")

ForEach objComputer in colComputer
    Wscript.Echo "Users: " & objComputer.UserName
Next

Wednesday, September 16, 2015

Monitor Active Directory Replication

Script to Monitor Active Directory Replication

strComputer = "."
#'.' is the local host
Set objWMIService = GetObject("winmgmts:" _
        strComputer & "\root\MicrosoftActiveDirectory")
Set colReplicationOperations = objWMIService.ExecQuery _
        ("Select * from MSAD_ReplPendingOp")
If colReplicationOperations.Count = 0Then
    Wscript.Echo "There are no replication jobs pending."
    Wscript.Quit
Else
    Foreach objReplicationJob in colReplicationOperations 
        Wscript.Echo "Serial number: " & objReplicationJob.SerialNumber
        Wscript.Echo "Time in queue: " & objReplicationJob.TimeEnqueued
        Wscript.Echo "DSA DN: " & objReplicationJob.DsaDN
        Wscript.Echo "DSA address: " & objReplicationJob.DsaAddress
        Wscript.Echo "Naming context DN: " & objReplicationJob.NamingContextDn
    Next
EndIf
    & "{impersonationLevel=impersonate}!\\" & _

Windows Server 2016 Key Features and License Prospects

If you are planning to move to Windows 2016 and looking for benefits, I have listed down below : Why Windows Server 2016? ·     ...