Here is a simple command that I would like to use a variable in.
(Get-Date).AddDays(-30)
What I'm trying to do is substitute a variable $Time for the word Days.
$Time="Days"
OR $Time="Hours"
Then run something like this:
(Get-Date).Add$Time(-30)
Is there a simple way to do this in 1 line?
Obviously I could write an If statement to do this but it seems like there should be a way to make this work in a single command.