Pages

Monday, February 6, 2017

VmWare Tools status from Virtual Machines

Get VmWare Tools status from Virtual Machines

Here is a simple PowerCli script which can be used to get the status of VmWare Tools on one or more virtual machines.


################################################################################################################
# The following Script can be used to fetch details about VmWare tools running on one or more virtula machines.
# Name of VM(s) can be specified at command prompt as parameter which is capable of accepting multiple VMs
# Make sure you are connected to the VC before attepting to run this script.
# This script will show the output on the console itself
# if you need the report in file then replace "ft -autosize" with export-csv -notypeinformation VMTools.csv
################################################################################################################
param(
[string[]]$ServerName
)
$ServerName |foreach
{
    $ComputerName = $_
    (get-vm $ComputerName).extensiondata.guest
} |select @{Name ="VMName" ; Expression = {"$ComputerName"}},ToolsStatus,ToolsVersionStatus,ToolsRunningStatus,ToolsVersion |ft -AutoSize




Sample Screenshot:



 Points to consider
  • Please make sure you are connected to the Virtual Center on PowerCli console before attempting to run this script.

Friday, February 3, 2017

Local Group members from Remote Computers

Fetch list of users from Local Group of Remote computers

Here is a simple PowerShell Script which can be used to fetch all the users who have either Administrative access on any server or are member of any specific Local Group on those servers.

############################################################################################################
# Read List of Server Names from the list input.txt
# Performs a Ping Test first before trying to fetch users from remote computers
# to ensure it attempts only reachable computers.
# Fetch members of local group on every server.
# The Local Group name can be modified according to the need like "Administrators" or "Remote Desktop Users"
############################################################################################################
 

Get-Content "input.txt" |foreach-object {
$Content = $_
# Loop only executed when ping is successful
if (test-connection -computername $Content -count 1 -quiet)
{
#Fetching details from servers
    ([ADSI]"WinNT://$_/Administrators").Members() | Select-Object `
        @{n='Computername';e={ $Content }},
        @{n='User/Group Name';e={ $_.GetType().InvokeMember('Name', 'GetProperty', $Null, $_, $Null) }},
        @{n='ADSPath';e={ $_.GetType().InvokeMember('ADSPath', 'GetProperty', $Null, $_, $Null) }},
        @{n='Type';e={ $_.GetType().InvokeMember('class', 'GetProperty', $Null, $_, $Null) }}
    }}| export-csv Local_Admins.csv –notypeinformation  


Copy the code above to a file and save that file as Get-LocalGroupMembers.ps1, Create another file named input.txt and put in all the servers in there (one server at one line), Save both of these files to same location and execute the script from PowerShell Console.

Points to consider:
*The user who is executing this script must have administrative rights on all the remote computers listed in input.txt.
* Name of Group can be changed according to the need to find out members of any local group on a remote computer like.. "Administrators" or "Remote Desktop Users" and so on..