I can't figure out why this script does not work

I am trying to run a script that is from Backblaze to install their desktop client. I think I have everything working right but I keep getting this error. Any help is greatly appreciated:

error> param : The term ‘param’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check
error> the spelling of the name, or if a path was included, verify that the path is correct and try again.
error> At C:\ProgramData\Syncro\bin\3ad5f3aa-7f23-45e7-92a6-021e49d610fa.ps1:4 char:1
error> + param(
error> + ~~~~~
error> + CategoryInfo : ObjectNotFound: (param:String) , CommandNotFoundException
error> + FullyQualifiedErrorId : CommandNotFoundException
error>

The script is below (pulled from their website with my variables added:

param(
[string] $groupID = $BBGroup,
[string] $groupToken = $BBToken,
[string] $userEmail = $BBEmail,
[string] $workingDirectory,
[string] $uninstall = “false”
)

#Create log if it doesnt already exist
$LOGNAME = “Backblaze Powershell Deployment”
if ( -not ( [System.Diagnostics.EventLog]::SourceExists($LOGNAME) ) ) {
New-EventLog -LogName Application -Source $LOGNAME
}

[int]$global:eventIx = 1

##############################FUNCTIONS#################################################
function logOutput {
param( [string]$out )
if ( $debug ) {
write-host “[debug[${global:eventIx}]] $out”
}
}

function global:echoOutput {
param( [string]$out )
Write-EventLog -LogName Application -Source $LOGNAME -EntryType Information -EventID $eventIX -Message $out
logOutput “event ${global:eventIx}: $out”
$global:eventIx = $global:eventIx + 1
}

function MyThrow {
param( [string]$throwMessage )
echoOutput $throwMessage
Throw $throwMessage
}

function updateCheck {
$software = “Backblaze”;
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall* | Where { $_.DisplayName -eq $software }) -ne $null

if($installed) {
    runUpdate
    exit
}

}

function runUpdate {

}

function installBackblaze {
$installCommand = “msiexec.exe /i install_backblazemsi.msi /quiet /l*vx! $BACKBLAZE_LOG_DIR BZEMAIL=$userEmail BZGROUPID=$groupID BZGROUPTOKEN=$groupToken”
Invoke-Expression $installCommand
}

function installADBackblaze {
$installADCommand = “msiexec.exe /i install_backblazemsi.msi /quiet /l*vx! $BACKBLAZE_LOG_DIR BZGROUPID=$groupID BZGROUPTOKEN=$groupToken”
Invoke-Expression $installADCommand
}

function uninstallBackblaze {
$uninstallCommand = “msiexec.exe /uninstall install_backblazemsi.msi /quiet”
Invoke-Expression $uninstallCommand
exit
}

########################################################################################

#Update Check

#Uninstall Check
if ( $uninstall -eq “true”) {
uninstallBackblaze
exit
}

#Set installer filename
$BACKBLAZE_INSTALLER = ‘install_backblazemsi.msi’
$BACKBLAZE_LOG = ‘output.log’

#Set install path
if ( $workingDirectory ) {
$BACKBLAZE_INSTALL_DIR = $workingDirectory
$BACKBLAZE_LOG_DIR = join-path $BACKBLAZE_INSTALL_DIR $BACKBLAZE_LOG
} else {
$BACKBLAZE_INSTALL_DIR = “C:\tmp\backblaze_install_dir”
$BACKBLAZE_LOG_DIR = “C:\tmp\backblaze_install_dir\output.log”
}

#Install path exists?
$ret = test-path $BACKBLAZE_INSTALL_DIR
echoOutput “BACKBLAZE_INSTALL_DIR [$BACKBLAZE_INSTALL_DIR] existence returned as ret [$ret]”
if( -not $ret ) {
New-Item -ItemType directory -Path $BACKBLAZE_INSTALL_DIR
echoOutput “Temp directory created at [$BACKBLAZE_INSTALL_DIR]”
}

$msiPath = join-path $BACKBLAZE_INSTALL_DIR $BACKBLAZE_INSTALLER

#Backblaze installer is present?
if ( -not ( test-path -path “$msiPath” ) ) {
Invoke-WebRequest -Uri “https://secure.backblaze.com/win32/install_backblazemsi.msi” -OutFile $msiPath
echoOutput “Latest installer download to [$BACKBLAZE_INSTALL_DIR]”
}

#Check parameters
if( -not $groupID ) {
MyThrow “Error: groupID missing”
}

if( -not $groupToken ) {
MyThrow “Error: groupToken missing”
}

Set-Location $BACKBLAZE_INSTALL_DIR

if ( $userEmail ) {
installBackblaze
} else {
installADBackblaze
}

Is param the very first non-commented line in your entire script? If anything is put before that, you will get that message.

yes, it is. Thank you for your response.

Gotcha. Looking at it a bit more not on my phone now I see it says Line 4 char 1… Is your BBEmail variable correct in Syncro as well? It almost looks like the character is messed up unless that happened when you were pasting it.

I ran it through my instance and it runs fine.

Yeah, that was the problem. I figured it out just as you sent this. Thank you!

1 Like

Hey there I’m using the same PS script from Backblaze and trying to run platform variables from syncro in it. The same error is coming up and the install keeps failing. Either Param is not recognized - Was this a formatting issue from the script that was copied?

Hi there,

This happens because when you use a script variable in a Syncro script, the variables will automatically be injected into the top of the script when Syncro runs it. This makes the “param” keyword not the first line in the script, leading to an error.

I am not aware of any workaround to this.