#requires -Version 2
Function Get-VDARegistration{
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[String[]]
$ComputerName,
[switch]
$ShowMessage
)
process{
foreach($Computer in $ComputerName){
$VDAEvent = Get-WinEvent -ErrorAction SilentlyContinue -MaxEvents 100 -ComputerName $Computer -FilterHashtable @{
logname = 'application'
id = 1012
} | Sort-Object -Property eventID
If ($VDAEvent){
$VDAMessage = $VDAEvent.Message|
Select-String -Pattern 'registered'|
Select-Object -First 1
If(($VDAMessage | Select-String -Pattern 'successfully')){
if($ShowMessage.IsPresent){
$props = @{
'Message' = $VDAMessage
'Registered' = $true
}
$obj = New-Object -TypeName PSObject -Property $props
Write-Output -InputObject $obj
}
else{
Write-Output -InputObject $true
}
}#end if VDALog.Message
else{
if($ShowMessage.IsPresent){
$props = @{
'Message' = $VDAMessage
'Registered' = $false
}
$obj = New-Object -TypeName PSObject -Property $props
Write-Output -InputObject $obj
}
else{
Write-Output -InputObject $false
}
}#end else VDALog.Message
}#end if VDALog
}#end foreach Computer
}#end process
}#end function Get-VDARegistration
Comments
0 B
|👍
/👎