Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Pass values from csv file to powershell scripts

$
0
0

I have a script that reads values from a CSV file and stores them as variables.

I then issue a Start-Job that launches another script using those variables.

I need the variables from the main script to be passed into the "child" script.

Here are the aforementioned scripts;

Powershell
Import-Module"sqlps"-DisableNameCheckingInvoke-Sqlcmd-Query"USE ASPNETDB; SELECT DATABASELOCATION, SITEID FROM FIREBIRDCONNECTIONS;"-ServerInstance"DV-SQLSTAG01\EXPRESS2014"|Export-CSV-Path"C:\Scripts\strings.csv"C:CDC:\Scripts$fbConn=Import-Csv-Path.\strings.csvForEach($sitein$fbConn){$cString=$site.DATABASELOCATION$siteid=$site.SITEID$backupDir="D:\DBBackups"$backupFile="Cpib_$siteid.bak"$logBackupStart="$(get-date-Uformat"%m/%d/%Y %r") - STARTING BACKUP OF SITE $siteid"$logBackupEnd="$(get-date-Uformat...

Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>