Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Get-Info {
- param(
- [parameter(Mandatory)]
- [alias('hostname')]
- [string]$ComputerName
- )
- BEGIN{
- }
- PROCESS{
- try{
- $Continue = $true
- $AdminPasswordStatus = Get-WmiObject -EA -stop -Class Win32_ComputerSystem -ComputerName $ComputerName | Select-Object -ExpandProperty AdminPasswordStatus
- $CS = Get-WmiObject -EA -stop -Class Win32_ComputerSystem -ComputerName $ComputerName | Select-Object -Property Domain,Model,Manufacturer
- $BS = Get-WmiObject -EA -stop -Class Win32_Bios -ComputerName $ComputerName | Select-Object -property SerialNumber
- $OS = Get-WmiObject -EA -stop -Class Win32_OperatingSystem -ComputerName $ComputerName | Select-Object -Property Version,ServicePackMajorVersion
- }
- catch {
- $Continue = $false
- $Computer = Out-File C:\errorlog.txt
- }
- if ($Continue = $true) {
- switch ($AdminPasswordStatus)
- {
- '1' {$AdminPasswordStatus = "Disabled"}
- '2' {$AdminPasswordStatus = "Enabled"}
- '3' {$AdminPasswordStatus = "NA"}
- '4' {$AdminPasswordStatus = "Unknown"}
- Default {"Sorry"}
- }
- $obj = [pscustomObject] @{
- ComputerName = $ComputerName;
- Domain = $CS.Domain;
- AdminPW = $AdminPasswordStatus
- Model = $cs.Model;
- Manufacturer = $CS.Maanufacturer;
- SerialNumber = $BS.SerialNumber;
- Version = $OS.Version;
- ServicePack = $OS.ServicePackMajorVersion}
- }
- }
- End{
- $obj
- }
- }
- Get-Info -ComputerName localhost
Advertisement
Add Comment
Please, Sign In to add comment