function Get-BasicOSinfo {
<#
.Synopsis
Gets basic Compuer OS Info
.Description
Gets basic OS Info from local or remote machines
.Parameter ComputerName
Name of the Computer (local or remote).
.Example
PS> get-BasicOSInfo -computername MycomputerName
PS> "computername" | get-BasicOSinfo
PS> get-content input.txt | get-BasicOSInfo
PS> import-csv input.csv | get-BasicOSInfo
.Link
about_functions
about_functions_advanced
about_functions_advanced_methods
about_functions_advanced_parameters
.Parameter ComputerName
Computername as a string to query
#>
[CmdletBinding()]
param(
[parameter(Position=0,Mandatory=$true,
ValueFromPipeline=$true,ValueFromPipeLineByPropertyName= $true)]
[String[]]$ComputerName
)
begin { $date = Get-Date -format MM/dd/yy } # Gather current date
process {
# Query WMI of local or remote system
$ComputerSystem = gwmi Win32_Computersystem -Computer $computername
$OperatingSystem = gwmi win32_operatingsystem -ComputerName $computername
$OS = $operatingSystem.caption
$user = $(($computerSystem.username.split("\"))[1])
$computer = $computersystem.caption
$domain = $computersystem.domain
# Populate table with tabs and newline/Carriage Return charaters
# then ouput to file in ascii format.
$result += "User:`t`t $user`r`n"
$result += "Computer:`t $computer`r`n"
$result += "Domain:`t`t $domain`r`n"
$result += "OS:`t`t $OS`r`n"
$result += "User information collected on:`t $date`r`n"
$result += "`r`n"
$result | Out-File result.txt -Encoding ascii
}
}
Wednesday, April 20, 2011
Scripting Games Beg5
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment