Gwith

Lab

May 21st, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. function Get-Info {
  2. param(
  3. [parameter(Mandatory)]
  4. [alias('hostname')]
  5. [string]$ComputerName
  6. )
  7.  
  8. BEGIN{
  9.  
  10. }
  11.  
  12. PROCESS{
  13.  
  14. try{
  15. $Continue = $true
  16. $AdminPasswordStatus = Get-WmiObject -EA -stop -Class Win32_ComputerSystem -ComputerName $ComputerName | Select-Object -ExpandProperty AdminPasswordStatus
  17. $CS = Get-WmiObject -EA -stop -Class Win32_ComputerSystem -ComputerName $ComputerName | Select-Object -Property Domain,Model,Manufacturer
  18. $BS = Get-WmiObject -EA -stop -Class Win32_Bios -ComputerName $ComputerName | Select-Object -property SerialNumber
  19. $OS = Get-WmiObject -EA -stop -Class Win32_OperatingSystem -ComputerName $ComputerName | Select-Object -Property Version,ServicePackMajorVersion
  20. }
  21. catch {
  22. $Continue = $false
  23. $Computer = Out-File C:\errorlog.txt
  24. }
  25.  
  26. if ($Continue = $true) {
  27. switch ($AdminPasswordStatus)
  28. {
  29. '1' {$AdminPasswordStatus = "Disabled"}
  30. '2' {$AdminPasswordStatus = "Enabled"}
  31. '3' {$AdminPasswordStatus = "NA"}
  32. '4' {$AdminPasswordStatus = "Unknown"}
  33. Default {"Sorry"}
  34. }
  35.  
  36. $obj = [pscustomObject] @{
  37. ComputerName = $ComputerName;
  38. Domain = $CS.Domain;
  39. AdminPW = $AdminPasswordStatus
  40. Model = $cs.Model;
  41. Manufacturer = $CS.Maanufacturer;
  42. SerialNumber = $BS.SerialNumber;
  43. Version = $OS.Version;
  44. ServicePack = $OS.ServicePackMajorVersion}
  45. }
  46. }
  47.  
  48. End{
  49. $obj
  50. }
  51. }
  52.  
  53.  
  54.  
  55.  
  56. Get-Info -ComputerName localhost
Advertisement
Add Comment
Please, Sign In to add comment