Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement