Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Need Help Passing Parameters

$
0
0

I have a script that accepts parameters, dynamically create and execute SQL commands to backup and restore Databases using a backup agent.  My desire is to use this script file in conjunction withe the "Start-Job" cmdlet so I can perform the process on multiple DB's at the same time.

It accepts the following parameters:

param
([string] $BackupServer, #Server to be backed up
 [string] $RestoreServer,#Server where backup is to be restore
 [string] $BackupDrive,  #Drive where backup file will be created
 [string] $DBName        #DB to be backed up and restored
 )

When I run it at the prompt as such:

\DB_Backup_Restore.ps1 "KCTS270" "WMDWM200D" "I$" "DW_Mart"

It work fine.

When I run  it at the prompt like this:

start-job -ScriptBlock {H:\PSHell\DB_Backup_Restore.ps1 } -ArgumentList "KCTS270", "WMDWM200D","I$", "DW_Core"

It runs and show up in the get-job info, but does nothing:

PS H:\pshell> get-job

Id              Name            State      HasMoreData     Location             Command                 
--              ----            -----      -----------     --------             -------                 
39              Job39           Running    True            localhost            H:\PSHell\DB_Backup_Re...
41              Job41           Running    True            localhost            H:\PSHell\DB_Backup_Re...

I have also tried it as:

start-job -ScriptBlock {H:\PSHell\DB_Backup_Restore.ps1 $BackupServer $RestoreServer $BackupDrive $DBName} -ArgumentList "KCTS270","WMDWM200D","I$","DW_Core"

start-job -filepath H:\PSHell\DB_Backup_Restore.ps1 -ArgumentList "KCTS270","WMDWM200D","I$","DW_Core"

start-job -ScriptBlock {H:\PSHell\DB_Backup_Restore.ps1 $args[0] $args[1] $args[2] $args[3]} -ArgumentList "KCTS270","WMDWM200D","I$","DW_Core"

All with similar results, I am fairly sure it has to do with the parameters not getting through, any thoughts?


Viewing all articles
Browse latest Browse all 10624

Trending Articles