Function silently fails on 64-bit PowerShell 1.0, runs as expected 32-bit PowerShell 1.0


is there not know powershell configuration , running script?  following behavior seems dangerous me:

64bit powershell v1.0: %systemroot%\system32\windowspowershell\v1.0\powershell.exe
and
32bit powershell v1.0: %systemroot%\syswow64\windowspowershell\v1.0\powershell.exe

  function backupdatabases  {  param ($server, $database_name, $username, $password)  	write-host "command: ", $command  	write-host "server: ", $server  	write-host "server: $server"  	write-host "username: ", $username  	write-host "username: $username"  	[system.console]::foregroundcolor = [system.consolecolor]::green  	sqlcmd -u $username -p $password -s $server -d master -i c:\scripts\backupdatabases.sql  	[system.console]::foregroundcolor = [system.consolecolor]::white  }  

on 64-bit, sqlcmd evaluates nothing.

to further confirm this, opened new 64-bit powershell , typed in sqlcmd.  nothing.

i opened new 32-bit powershell , typed in sqlcmd. got sqlcmd interactive command prompt > arrow, suggesting sqlcmd running.

running x64 powershell console not have issue. if you're unable execute sqlcmd x64 path problem. first determine sqlcmd located x86 powershell:

get-command sqlcmd

next x64 powershell console take @ environmental path variable:

$env:path -split ";"

more path calling sqlcmd isn't defined or in directory sqlcmd located in x86.



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file