0

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

5
  • 2
    What kind of "security reason" would that be? Commented Feb 23, 2011 at 9:30
  • we have to use "Set-ExecutionPolicy AllSigned" and this is afraid us for remote execution code that down our server Commented Feb 23, 2011 at 18:04
  • 2
    Sign your scripts. Here is a [starter article].(blogs.technet.com/b/heyscriptingguy/archive/2010/06/16/…) Commented Feb 24, 2011 at 8:08
  • It's not really for "security reasons" then, is it? It's to subvert security. Commented Feb 24, 2011 at 21:54
  • yes, its just about security, when we set executionPolicy allsigned its a little bit frightening. Commented Feb 25, 2011 at 20:19

1 Answer 1

2

Do you really want to go backwards? Do you fully understand what the ExecutionPolicy is for and how to use it?

The execution policy is more or less for user protection against automated scripts. As the PowerShell Team puts it here,

PowerShell trust user input, and runs it as-is. ...Execution Policies are a user feature. Like seatbelts. It's best to keep them on, but you always have the option to take them off.

I don't follow how it can be "frightening" to set the execution policy? I consider it a bit more frightening to allow users access to the Internet :)

If you are worried about scripts being executed on the server in question, then protect the server by preventing who has direct and remote access to the server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.