Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. [CmdletBinding()]
  2. Param(
  3. [Parameter(Mandatory=$False)]
  4. [array]$ComputerName,
  5. [Parameter(Mandatory=$False)]
  6. [switch]$RunningProcesses,
  7. [Parameter(Mandatory=$False)]
  8. [switch]$ComputerInfo,
  9. [Parameter(Mandatory=$False)]
  10. [switch]$Updates,
  11. [Parameter(Mandatory=$False)]
  12. [switch]$LocalUsers,
  13. [Parameter(Mandatory=$False)]
  14. [switch]$DomainUsers,
  15. [Parameter(Mandatory=$False)]
  16. [switch]$Services
  17. )
  18.  
  19. Import-Module ActiveDirectory
  20.  
  21. if ($ComputerName) {
  22. Write-Output "Gathering Information for: $($ComputerName -join ", ")"
  23. }
  24.  
  25. if ($RunningProcesses) { getRunningProcesses }
  26. if ($ComputerInfo) { getComputerInfo }
  27. if ($Updates) { getUpdates }
  28. if ($LocalUsers) { getLocalUsers }
  29. if ($DomainUsers) { getDomainUsers }
  30. if ($Services) { getServices }
  31.  
  32. function getRunningProcesses {
  33. Write-Output "Running Processes: "
  34. if ($ComputerName) {
  35. Get-Process -ComputerName $ComputerName
  36. } else {
  37. Get-Process
  38. }
  39. }
  40.  
  41. function getComputerInfo {
  42. #Domain, CPU Manufacturer, system Manufacturer, Version, Physical Memory,
  43. #Max Clock Speed, Model, Computer Name
  44. Write-Output "Computer Info: "
  45. if ($ComputerName) {
  46. $os = Get-WmiObject -ComputerName $ComputerName -Class Win32_OperatingSystem
  47. $vol = Get-WmiObject -ComputerName $ComputerName -Class Win32_Volume
  48. $net = Get-WmiObject -ComputerName $ComputerName -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPAddress -ne $null }
  49. } else {
  50. $os = Get-WmiObject -Class Win32_OperatingSystem
  51. $vol = Get-WmiObject -Class Win32_Volume
  52. $net = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPAddress -ne $null }
  53. }
  54. Write-Output "OS:"
  55. Write-Output $os
  56. Write-Output "Volumes:"
  57. Write-Output $vol
  58. Write-Output "NICs:"
  59. Write-Output $net
  60. }
  61.  
  62. function getUpdates {
  63. # could use Invoke-Expression "wmic qfe list" for wmi
  64. Write-Output "Currently Installed Updates: "
  65. if ($ComputerName) {
  66. Get-Hotfix -ComputerName $ComputerName
  67. } else {
  68. Get-HotFix
  69. }
  70. }
  71.  
  72. function getLocalUsers {
  73. Write-Output "Local Users: "
  74. if ($ComputerName) {
  75. Get-ADUser -Filter * -SearchBase "dc=local" -ComputerName $ComputerName
  76. } else {
  77. Get-ADUser -Filter * -SearchBase "dc=local"
  78. }
  79. }
  80.  
  81. function getDomainUsers {
  82. Write-Output "Domain Users: "
  83. if ($ComputerName) {
  84. Get-ADUser -Filter * -SearchBase "dc=domain" -ComputerName $ComputerName
  85. } else {
  86. Get-ADUser -Filter * -SearchBase "dc=domain"
  87. }
  88. }
  89.  
  90. function getServices {
  91. Write-Output "Services: "
  92. if ($ComputerName) {
  93. Get-Service -ComputerName $ComputerName
  94. } else {
  95. Get-Service
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement