PeterSinger
asked on
Powershell time within 2 minutes of listed
Hi,
I have a powershell script that I am comparing the two fields;
Get-QADGroup UGL-SM-Map.Shared-Full |ft ModificationDate, Description
ModificationDate Description
---------------- -----------
13/09/2011 10:55:37 AM 13/09/2011 10:55:37 AM
ModificationDate Description
---------------- -----------
13/09/2011 10:55:37 AM 13/09/2011 10:55:39 AM
I want to say if the date and time is -eq or within 2 minutes of each other then return true if not return false.
Help please :)
I have a powershell script that I am comparing the two fields;
Get-QADGroup UGL-SM-Map.Shared-Full |ft ModificationDate, Description
ModificationDate Description
---------------- -----------
13/09/2011 10:55:37 AM 13/09/2011 10:55:37 AM
ModificationDate Description
---------------- -----------
13/09/2011 10:55:37 AM 13/09/2011 10:55:39 AM
I want to say if the date and time is -eq or within 2 minutes of each other then return true if not return false.
Help please :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$day and $month round the wron way. Thenks working nicely.
ASKER
Very Nice, thanks.
ASKER
I get the below back;
Get-Date : Cannot bind parameter 'Date'. Cannot convert value "09/13/2011" to type "System.DateTime". Error: "String wa
s not recognized as a valid DateTime."
At D:\Scripts\SharedMailboxes
+ get-date <<<< "$month/$day/$year" -Month $month -hour $hour -minute $minute
+ CategoryInfo : InvalidArgument: (:) [Get-Date], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMes
Get-Date : Cannot bind parameter 'Date'. Cannot convert value "09/13/2011" to type "System.DateTime". Error: "String wa
s not recognized as a valid DateTime."
At D:\Scripts\SharedMailboxes
+ get-date <<<< "$month/$day/$year" -Month $month -hour $hour -minute $minute
+ CategoryInfo : InvalidArgument: (:) [Get-Date], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMes
New-TimeSpan : Cannot bind parameter 'End' to the target. Exception setting "End": "Object reference not set to an inst
ance of an object."
At D:\Scripts\SharedMailboxes
+ If ((New-TimeSpan <<<< (Format-time $($group.ModificationDate)
){
+ CategoryInfo : WriteError: (:) [New-TimeSpan], ParameterBindingException
+ FullyQualifiedErrorId : ParameterBindingFailed,Mic