I am new to PowerShell and stuck on how to complete the next step in my script. I realise it probably inst the best way to do this but its what i came up with. The scenario is that i need to check that our backups are creating a weekly archive, i have created the below and happy for suggestions on a better way to do it but not what my question is. I want to know if there is a way to have an if statement for all the other If/Else statements in the script. To expand on this is want to have an if statement so that is the other if/else statements comes back as archives are ok then it just outputs one “archives are ok” message rather than the 4 it currently outputs. Also if one fails it just tells you which has failed. Any help would be appreciated TIA Leon.
internet = (Get-Item “THEACTUALPATH”).LastWriteTime
$a3 = (Get-Item “THEACTUALPATH”).LastWriteTime
$cn3 = (Get-Item “THEACTUALPATH”).LastWriteTime
$management = (Get-Item “THEACTUALPATH”).LastWriteTime
$date = {
(Get-Date).Date;
(Get-Date).AddDays(+1);
(Get-Date).AddDays(+2);
(Get-Date).AddDays(+3);
(Get-Date).AddDays(+4);
(Get-Date).AddDays(+5);
(Get-Date).AddDays(+6)
}
if ($internet = $date)
{ “Internet servers archives ok”}
Else
{ “Internet servers archive failed”}
if ($n3 = $date)
{ "N3 Servers archives ok"}
Else
{ “N3 Server archive failed”}
if ($cn3 = $date)
{ "CN3 Servers archives ok"}
Else
{ “CN3 Servers archive failed”}
if ($management = $date)
{ "Management Servers archives ok"}
Else
{ “Management Servers archive failed”}