Heyvoon
Heyvoon

Reputation: 71

How to run a batch script contained in a variable in a Powershell script?

I have the following batch script as variable in my powershell script.

$DataIntegrityCheck = @"
@ECHO OFF
SET SETTING_HOME=""
SET BACKUP_SET="ALL"
SET BACKUP_DEST="ALL"
SET CRC_MODE="DISABLE-CRC"
"@

How can I run this batch script?

Thank you in advance for any help.

Upvotes: 0

Views: 139

Answers (1)

Maximilian Burszley
Maximilian Burszley

Reputation: 19664

You don't need to execute that in batch to set environment variables, just use the Environment drive in :

$Env:SETTING_HOME = '""'
$Env:BACKUP_SET = '"ALL"'
$Env:BACKUP_DEST = '"ALL"'
$Env:CRC_MODE = '"DISABLE-CRC"'

about_Environment_Provider

Upvotes: 2

Related Questions