We have 2 powershell scripts. The first one is written for Copy the new Files from SAN to NAS storage and delete older files in destination, as follows:
$a = Get-ChildItem h:\destination
foreach($x in $a)
{ $y = ((Get-Date) - $x.CreationTime).Days
if ($y -gt 6 -and $x.PsISContainer -ne $True)
{$x.Delete()}
}
foreach ($i in Get-ChildItem k:\SourceFolder)
{
if ($i.CreationTime -gt ($(Get-Date).Adddays(-1)))
{
Copy-Item $i.FullName h:\destination\
}
}
and the Second one is for running Windows ntbackup.exe to backup system state and delete older backup files
$date = ( get-date ).ToString('yyyyMMdd')
ntbackup backup systemstate /J "Backup Job 1" /F "C:\test\$date-backup.bkf"
$a = Get-ChildItem c:\test
foreach($x in $a)
{ $y = ((Get-Date) - $x.CreationTime).Days
if ($y -gt 6 -and $x.PsISContainer -ne $True)
{$x.Delete()}
}
for security reason I want to use vbscript of these 2 codes for running on my servers. any suggestion we`ll be appreciated
s just about security, when we set executionPolicy allsigned its a little bit frightening.