Navision database service mading by powershell

niespielakniespielak Member Posts: 2
Hello everyone,
a few days ago i started to learn powershell. For first time i want to write script witch i baseing on this standard batch:
echo "Native server instaltaion"
"C:\Program Files\Microsoft Business Solutions-Navision\Database Server\server.exe" database="D:\Navision Database\rbo370pos.fdb",cache=50000,servername=%COMPUTERNAME%-NDB,nettype=tcp,installasservice
echo "...finished."

echo "Server configuration..."
echo Windows Registry Editor Version 5.00 > NDBManualStart.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\%COMPUTERNAME%-NDB] >> NDBManualStart.reg
echo "Start"=dword:00000003 >> NDBManualStart.reg
regedit /s NDBManualStart.reg
del /q NDBManualStart.reg
echo "...finished"

I write this powershell script:
$localization = get-content env:computername
$dbpath = 'database="E:\Navision\Instalacja LSR\Katalogi LSR\NavisionDatabase\rbo370pos.fdb"'
$cache = "cache=500000"
$nettype = "nettype=tcp"
$servername = "$localization"
$servernav = "C:\Program Files\Microsoft Business Solutions-Navision\Database Server\server.exe" 
$BinaryPathName = "$servernav $dbpath,$nettype,$cache"

Write-Output "Native database server instaltion for: $localization"
New-Service -name $servername-NDB -binaryPathName $BinaryPathName -StartupType Manual

I know that my script is wrong - batch is starting server.exe with parametrs. My script is adding parameters to path server.exe.
How have I rewrite this script? Maybe i can save parameters for this service in some ini file?
Sign In or Register to comment.