This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-Uptime { | |
<# | |
.Synopsis | |
Gets uptime of computers via WMI and displays results in hours, mins and seconds. | |
.Description | |
Gets uptime of computers and displays results in hours, mins and seconds. Written for http://blogs.technet.com/b/heyscriptingguy/archive/2013/04/18/advanced-practice-for-2013-scripting-games.aspx | |
.Parameter ComputerName | |
The hostname, alias, or IP of the computer from which to get the uptime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function IsPingable { | |
<# | |
.Synopsis | |
Pings a server and returns TRUE or FALSE. | |
.Description | |
Uses WMI to ping a server, and returns TRUE if a status code of 0 is returned, otherwise returns FALSE. Useful for quick checks to see if a server exists and is online. | |
.Parameter Computer | |
The computer's Hostname, FQDN, or IP to be pinged. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-LockedADAccounts { | |
<# | |
.Synopsis | |
Gets lockout events from event logs on domain controllers | |
.Description | |
Searches event logs of domain controllers for event ID 4740, and returns the time the event was logged (LockedTime), the user account SamAccountName (Account), the source computer (LockedFrom), and the current locked status (Locked) | |
.Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-LockedADAccounts { | |
<# | |
.Synopsis | |
Gets lockout events from event logs on domain controllers | |
.Description | |
Searches event logs of domain controllers for event ID 4740, and returns the time the event was logged (LockedTime), the user account SamAccountName (Account), the source computer (LockedFrom), and the current locked status (Locked) | |
.Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the name of the machine from the user | |
$strVM = Read-Host "Please enter the VM name" | |
# Attempt to get a machine-object with that name, continue silently if no machine found | |
$objectVM = Get-VM -Name $strVM -ErrorAction SilentlyContinue | |
# If there is a machine found | |
If ($objectVM) { | |
# Display the machine object name on screen | |
Write-Host "Machine object name:" $objectVM.Name | |
# Display the power state on screen | |
Write-Host "Power State:" $objectVM.PowerState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loop through each VM | |
ForEach ($objVM in ( | |
Get-VM | Where-Object { | |
# Where the configured memory is greater than 2000 | |
$_.MemoryMB -gt "2000" | |
} | |
)){ | |
# Get the VM guest object | |
Get-VMGuest -VM $objVM | Where-Object { | |
# Where the operating system is Windows XP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Write-Log { | |
<# | |
.Synopsis | |
Writes timestamped output to screen and a logfile. | |
.Description | |
Writes timestamped output to screen and a logfile. | |
.Parameter Message | |
Message to be displayed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-AppSenseLogonTimes { | |
<# | |
.Synopsis | |
Returns information about AppSense logon events as recorded by the AppSense event log | |
.Description | |
Returns, via the AppSense Event log, the Logon Time, Node Name, Action, Start Time and Duration of AppSense logon actions. | |
Useful for tuning and optimising AppSense logons. | |
The Policy Configuration item "Send events to the Appsense event log" should be enabled for this to work. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get all of the VMs as an object | |
$objVMs = Get-VM | |
# Loop through all of the VMs | |
ForEach ($objVM in $objVMs){ | |
# Get the VM Guest object (which contains the DNS information) | |
$objGuest = Get-VMGuest -VM $objVM | |
# Set a variable to the VM object name | |
$objVMName = $objVM.Name | |
# Set a variable to the DNS name | |
$objVMFQDN = $objGuest.Hostname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set up an empty array | |
$arrTemplatesWithPersistentDrives = @() | |
# Get all the template objects | |
$objTemplates = Get-Template | |
# Loop through each template | |
ForEach ($objTemplate in $objTemplates){ | |
# Get the drives associated with that template | |
$objHardDisks = $objTemplate | Get-HardDisk |
OlderNewer