1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| #Output
#(.\CheckServices.ps1 [Hostname of Laptop that to be send out] | Out-File \\[Hostname of your laptop]\C$\TEMP\[Hostname of Laptop that to be send out]_Services.txt)
#example: .\CheckServices.ps1 RTH006666 | Out-File \\RTH014662\C$\TEMP\RTH006666_Services.txt
[CmdletBinding()]
Param(
[Parameter(Mandatory)]
[string]$Hostname
)
function Check-IsElevated {
$id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$p = New-Object System.Security.Principal.WindowsPrincipal($id)
if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
{
Write-Output $true
}
else
{
Write-Output $false
}
}
function GetService {
$out = @()
$sys = Get-WmiObject -ComputerName $Hostname -class Win32_ComputerSystem
$SerialNumber = Get-WmiObject -ComputerName $Hostname -class Win32_BIOS
$UserName = Get-CimInstance Win32_ComputerSystem -ComputerName $Hostname | Select -ExpandProperty username
$TcpIpV4 = (Get-WmiObject -ComputerName $Hostname -Class Win32_NetworkAdapterConfiguration | where {$_.DefaultIPGateway -ne $null}).IPAddress | select-object -First 1
$NetworkAdapter = Get-WmiObject win32_networkadapterconfiguration -Comp $hostname | where {$_.DHCPEnabled -and $_.DNSDomain -ne $null}
$MACADDRESS = $networkadapter.MACAddress
$os = Get-WmiObject -ComputerName $Hostname -class win32_operatingsystem
$wmi_os = Get-WmiObject -class Win32_OperatingSystem -ComputerName $Hostname| Select-Object Caption
$vbios = Get-WmiObject -class Win32_BIOS -ComputerName*$hostname*|Select-Object -Property Name,caption
$winver = Invoke-Command -computerName $HostName -ScriptBlock {(Get-ItemProperty registry::'\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion').Displayversion}
$BitLocker = (manage-bde -status -computername $Hostname C: | where {$_ -match 'Protection Status'}).Split(":")[1].trim()
$MDOP = Get-WmiObject -ComputerName $Hostname -Class Win32_Product | where Name -like "MDOP*" | select Version
$line = "---------------------------------------------------------------------------------------------"
$enter = "`n"
$today = Get-Date
$DeviceInfo= @{}
$DeviceInfo.add("System Name", $sys.Name)
$DeviceInfo.add("Model", $sys.Model)
$DeviceInfo.add("SerialNumber", $SerialNumber.SerialNumber)
$DeviceInfo.add("Version Bios" , ($vbios.Name))
$DeviceInfo.add("UserName" , $UserName)
$DeviceInfo.add("TcpIpV4" , $TcpIpV4)
$DeviceInfo.add("Mac Address" , $MACADDRESS)
$DeviceInfo.add("Windows Version", $os.Version)
$DeviceInfo.add("Display Version", $winver)
$DeviceInfo.add("Build Number", $os.BuildNumber)
$DeviceInfo.add("Os Description" ,$wmi_os.Caption)
$DeviceInfo.add("Architecture", $os.OSArchitecture)
$DeviceInfo.add("Build Date", ([WMI]'').ConvertToDateTime($os.InstallDate))
$DeviceInfo.add("BitLocker", $BitLocker)
$DeviceInfo.add("MDOP MBAM Version", $MDOP)
$out += New-Object PSObject -Property $DeviceInfo | Select-Object `
"System Name", `
"Model", `
"SerialNumber", `
"Bios Version", `
"UserName", `
"TcpIpV4", `
"Mac Address", `
"Windows Version", `
"Build Number", `
"Os Description",
"Display Version", `
"Architecture", `
"Build Date", `
"BitLocker", `
"MDOP MBAM Version"
$out2 = Get-Service -ComputerName $Hostname FA_Scheduler, `
McAfeeFramework, `
macmnsvc, `
masvc, `
MfeFfCoreService, `
mfemms, `
mfevtp, `
WdNisSvc, `
WinDefend, `
Sense, `
mpssvc, `
'Nexthink Service', `
'Nexthink Coordinator', `
QualysAgent, `
CcmExec, `
bomgar-ps* ,
QualysAgent | ft
$enter
$today
$line
$out
$line
$out2
$TotalRecord = ($out2).count -4
$out3 = Write-Host $TotalRecord "Services"
$out4 = Get-Hotfix -ComputerName $Hostname | Format-Table -AutoSize
$out5 = Get-hotfix -ComputerName $Hostname | Group-Object -Property Description | Select Name,Count
$line
$out4
$line
$out5
}
if (-not (Check-IsElevated))
{
$enter
Write-Host "Please run this script as an administrator!!"
}
elseif(Test-Connection -BufferSize 32 -Count 1 -ComputerName $Hostname -Quiet)
{
GetService
}
else
{
Write-Host "The remote machine is not Online! "
} |
Partager