I wish to set the System.DateTime object below with the time from $time:
$CurrentTime = (date)
$Time = "9:00"
How do I get the date from $CurrentTime, but with hours, minutes, seconds from $time?
Try this:
[datetime]::ParseExact("09:00","hh:mm",$null)
Get-Date -Year $CurrentTime.Year `
-Month $CurrentTime.Month `
-Day $CurrentTime.Day `
-Hour $time.split(':')[0] `
-Minute $time.split(':')[-1]
-Second $time.split(':')[-1]