Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [CmdletBinding()]
- Param(
- [Parameter(Mandatory=$False)]
- [array]$ComputerName,
- [Parameter(Mandatory=$False)]
- [switch]$RunningProcesses,
- [Parameter(Mandatory=$False)]
- [switch]$ComputerInfo,
- [Parameter(Mandatory=$False)]
- [switch]$Updates,
- [Parameter(Mandatory=$False)]
- [switch]$LocalUsers,
- [Parameter(Mandatory=$False)]
- [switch]$DomainUsers,
- [Parameter(Mandatory=$False)]
- [switch]$Services
- )
- Import-Module ActiveDirectory
- if ($ComputerName) {
- Write-Output "Gathering Information for: $($ComputerName -join ", ")"
- }
- if ($RunningProcesses) { getRunningProcesses }
- if ($ComputerInfo) { getComputerInfo }
- if ($Updates) { getUpdates }
- if ($LocalUsers) { getLocalUsers }
- if ($DomainUsers) { getDomainUsers }
- if ($Services) { getServices }
- function getRunningProcesses {
- Write-Output "Running Processes: "
- if ($ComputerName) {
- Get-Process -ComputerName $ComputerName
- } else {
- Get-Process
- }
- }
- function getComputerInfo {
- #Domain, CPU Manufacturer, system Manufacturer, Version, Physical Memory,
- #Max Clock Speed, Model, Computer Name
- Write-Output "Computer Info: "
- if ($ComputerName) {
- $os = Get-WmiObject -ComputerName $ComputerName -Class Win32_OperatingSystem
- $vol = Get-WmiObject -ComputerName $ComputerName -Class Win32_Volume
- $net = Get-WmiObject -ComputerName $ComputerName -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPAddress -ne $null }
- } else {
- $os = Get-WmiObject -Class Win32_OperatingSystem
- $vol = Get-WmiObject -Class Win32_Volume
- $net = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object { $_.IPAddress -ne $null }
- }
- Write-Output "OS:"
- Write-Output $os
- Write-Output "Volumes:"
- Write-Output $vol
- Write-Output "NICs:"
- Write-Output $net
- }
- function getUpdates {
- # could use Invoke-Expression "wmic qfe list" for wmi
- Write-Output "Currently Installed Updates: "
- if ($ComputerName) {
- Get-Hotfix -ComputerName $ComputerName
- } else {
- Get-HotFix
- }
- }
- function getLocalUsers {
- Write-Output "Local Users: "
- if ($ComputerName) {
- Get-ADUser -Filter * -SearchBase "dc=local" -ComputerName $ComputerName
- } else {
- Get-ADUser -Filter * -SearchBase "dc=local"
- }
- }
- function getDomainUsers {
- Write-Output "Domain Users: "
- if ($ComputerName) {
- Get-ADUser -Filter * -SearchBase "dc=domain" -ComputerName $ComputerName
- } else {
- Get-ADUser -Filter * -SearchBase "dc=domain"
- }
- }
- function getServices {
- Write-Output "Services: "
- if ($ComputerName) {
- Get-Service -ComputerName $ComputerName
- } else {
- Get-Service
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement