<#
.SYNOPSIS
This script uses WMI to get the name of a computer's domain then displays the name.
.DESCRIPTION
This script is a re-write of an MSDN sample, using PowerShell.
.NOTES
File Name : Get-ComputerDomain.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell Version 2.0
.LINK
This script posted to:
http://www.pshscripts.blogspot.com
MSDN sample posted tot:
http://msdn.microsoft.com/en-us/library/aa394586%28VS.85%29.aspx/
.EXAMPLE
PSH [C:\foo]: .\Get-ComputerDomain.ps1
System Name: WIN7
Domain: cookham.net
.EXAMPLE
Psh[Cookham8]> .\Get-ComputerDomain.ps1 cookham2
System Name: COOKHAM2
Domain: cookham.net
.PARAMETER comp
The name of the computer whose domain name to be displayed. Default is localhost.
#>
# Parameter block
param (
$comp = "."
)
# Get WMI Object
$system = Get-WmiObject -class Win32_ComputerSystem -ComputerName $comp
# Display results
"System Name: {0}" -f $System.Name
"Domain: {0}" -f $System.Domain
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Showing posts with label win32_computersystem. Show all posts
Showing posts with label win32_computersystem. Show all posts
Tuesday, 4 January 2011
Get-ComputerDomain.ps1
Labels:
PowerShell scripts,
win32_computersystem,
wmi
Tuesday, 17 August 2010
Get-BrokenHardware.ps1
- <#
- .SYNOPSIS
- This script gets a list of non-working hardware using WMI.
- .DESCRIPTION
- This script re-implements another TechNet Scripting
- Gallery script that was written in VB (see
- http://tinyurl.com/y4hmtbr).
- This script first uses WMI to get system details, then
- gets and displays hardware that has errored.
- .NOTES
- File Name : Get-BrokenHardware.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- This script posted to TechNet Script Gallery at:
- http://gallery.technet.microsoft.com/ScriptCenter/en-us/dbb678f4-b95b-45c3-bc8b-2ae2d052448e
- .EXAMPLE
- PSH [C:\foo]: Get-BrokenHardware.ps1
- Computer Details:
- Manufacturer: Dell Inc.
- Model: Precision WorkStation T7400
- Service Tag: 6Y84C3J
- Hardware that's not working list
- Description: WD My Book Device USB Device
- Device ID: USBSTOR\OTHER&VEN_WD&PROD_MY_BOOK_DEVICE&REV_1010\7&2A4E07C&0&575532513130303732383932&1
- Error ID: 28
- #>
- # Display Computer details
- "Computer Details:"
- $comp = gwmi Win32_ComputerSystem
- "Manufacturer: {0}" -f $comp.Manufacturer
- "Model: {0}" -f $comp.Model
- $computer2 = Get-WmiObject Win32_ComputerSystemProduct
- "Service Tag: {0}" -f $computer2.IdentifyingNumber
- ""
- #Get hardware that is errored
- "Hardware that's not working list"
- $broken = Get-WmiObject Win32_PnPEntity | where {$_.ConfigManagerErrorCode -ne 0}
- #Display broken hardware
- foreach ($obj in $broken){
- "Description: {0}" -f $obj.Description
- "Device ID: {0}" -f $obj.DeviceID
- "Error ID: {0}" -f $obj.ConfigManagerErrorCode
- ""
- }
Technorati Tags: PowerShell,Scripts,WMI,Win32_ComputerSystem,Win32_ComputerSystemProduct,Win32_PnPEntity
Tuesday, 13 January 2009
Get-UpTime.ps1
- <#
- .SYNOPSIS
- Demonstrates uptime using WMI
- .DESCRIPTION
- This script used Win32_ComputerSystem to determine how long your system
- has been running. This is a rewrite/improvement of sample 3 at
- http://msdn.microsoft.com/en-us/library/aa394591(VS.85).aspx.
- .NOTES
- File Name : Get-UpTime.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- Script Posted to:
- http://www.pshscripts.blogspot.com
- Original sample posted at:
- http://msdn.microsoft.com/en-us/library/aa394591(VS.85).aspx
- .EXAMPLE
- PS c:\foo> .\Get-UpTime.Ps1
- System Up for: 1 days, 8 hours, 40.781 minutes
- #>
- ##
- # Start of script
- ##
- # Helper Function - convert WMI date to TimeDate object
- function WMIDateStringToDate($Bootup) {
- [System.Management.ManagementDateTimeconverter]::ToDateTime($Bootup)
- }
- # Main script
- $Computer = "." # adjust as needed
- $computers = Get-WMIObject -class Win32_OperatingSystem -computer $computer
- foreach ($system in $computers) {
- $Bootup = $system.LastBootUpTime
- $LastBootUpTime = WMIDateStringToDate($Bootup)
- $now = Get-Date
- $Uptime = $now - $lastBootUpTime
- $d = $Uptime.Days
- $h = $Uptime.Hours
- $m = $uptime.Minutes
- $ms= $uptime.Milliseconds
- "System Up for: {0} days, {1} hours, {2}.{3} minutes" -f $d,$h,$m,$ms
- }
- # End script
Tuesday, 2 December 2008
Get-PhysicalRam.ps1
# Get-PhysicalRAM.ps1
# Sample using PowerShell
# 3rd sample from http://msdn.microsoft.com/en-us/library/aa394587
# Thomas Lee
$mem = Get-WmiObject -Class Win32_ComputerSystem
# Display memory
"This system has {0} MB Free Memory" -f $($mem.TotalPhysicalMemory/1mb)
PS C:\foo> .\Get-PhysicalRAM
This system has 8188.7421875 MB Free Memory
Labels:
powershell,
PowerShell scripts,
win32_computersystem,
wmi
Subscribe to:
Posts (Atom)