Skip to main content
Version: 7.0

Windows Server

danger

This instruction assumes the following locations for components and Passwork:

  • Passwork location — C:\inetpub\wwroot\passwork
  • PHP8.3 location — C:\Program Files\php8.3
  • Passwork website name in IIS web server — Passwork Web Site

Preparation

Open PowerShell as "Administrator":

Using the Start context menu
  1. Right-click on the Start icon in the lower-left corner of the screen.
  2. Select "Windows PowerShell (Administrator)" from the context menu.
Using the Start menu
  1. Left-click on the Start icon in the lower-left corner of the screen.
  2. Type powershell
  3. Open PowerShell as "Administrator" using the shortcut — Ctrl + Shift + Enter

To check the Passwork location and website name, you can run the following code:

# Import the module
Import-Module WebAdministration

# Get the list of all sites in IIS
$sites = Get-Website

# Output header
Write-Host "`n--- List of sites in IIS ---`n" -ForegroundColor Blue

foreach ($site in $sites) {
Write-Host "Site: " -NoNewline -ForegroundColor White
Write-Host $site.Name -ForegroundColor DarkGreen

# Get Bindings
Write-Host " Bindings:" -ForegroundColor DarkCyan
foreach ($binding in $site.Bindings.Collection) {
Write-Host " - Protocol: " -NoNewline -ForegroundColor Gray
Write-Host $binding.Protocol -ForegroundColor White

Write-Host " Address: " -NoNewline -ForegroundColor Gray
Write-Host $binding.BindingInformation -ForegroundColor White
}

# Get physical path
$physicalPath = (Get-WebConfigurationProperty -Filter "system.applicationHost/sites/site[@name='$($site.Name)']/application[@path='/']/virtualDirectory[@path='/']" -Name physicalPath).Value
Write-Host " Physical path: " -NoNewline -ForegroundColor DarkCyan
Write-Host $physicalPath -ForegroundColor White

Write-Host "------------------------------------" -ForegroundColor DarkGray
}

Obtaining current version of Passwork

Create a temporary directory to receive Passwork:

New-Item -Path "$env:WinDir\Temp\update_passwork" -ItemType Directory
danger

If the server with Passwork is located in a closed network, you need to go to the Passwork Customer Portal and manually obtain version 7 and move it to the server in the directory named — C:\Windows\Temp\update_passwork\passwork.zip

Go to the Passwork Customer Portal and copy the API key to obtain the current version:

Obtaining API key on the client portal

Create the API_KEY variable:

$API_KEY = "your_api_key"

Check the available Passwork version from the client portal using the copied API key with the request:

Invoke-RestMethod -Uri "https://portal.passwork.pro/api/version?apikey=$API_KEY" -Method Get
Correct output
response
--------
@{last-available-version=07xxxx}
danger

Make sure that version 7 of Passwork is available for download — 07xxxx

Download version 7 of Passwork with the request:

try {
(New-Object System.Net.WebClient).DownloadFile(
"https://portal.passwork.pro/api/download?apikey=$API_KEY",
"$env:WinDir\Temp\update_passwork\passwork.zip"
)
Write-Output "Passwork archive successfully obtained"
} catch {
Write-Output "Error obtaining Passwork: $_"
}

Clear the API_KEY variable:

Remove-Variable API_KEY

Updating to current version

Get the current Passwork version into a variable:

$version = Get-Content "$env:SystemDrive\inetpub\wwwroot\passwork\version"

Copy the Passwork configuration file to a separate directory:

Copy-Item -Path "$env:SystemDrive\inetpub\wwwroot\passwork\app\config\config.ini" -Destination "$env:SystemDrive\inetpub\wwwroot\"

Create an archive of the current Passwork version for rollback possibility:

Compress-Archive -Path "$env:SystemDrive\inetpub\wwwroot\passwork\*" -DestinationPath "$env:SystemDrive\inetpub\wwwroot\passwork-$version.zip" -Force

Delete all contents from the Passwork directory:

Remove-Item -Path "$env:SystemDrive\inetpub\wwwroot\passwork\*" -Recurse -Force

Extract version 7 of Passwork to the physical location:

Expand-Archive -Path "$env:WinDir\Temp\update_passwork\passwork.zip" -DestinationPath "$env:SystemDrive\inetpub\wwwroot\passwork\"

Download rewrite rules (web.config) and place them in the new Passwork version — $env:SystemDrive\inetpub\wwwroot\passwork\public\web.config

web.config

Registering PHP and activating extensions

Import IIS modules and register the PHP version:

Import-Module IISAdministration
Add-PsSnapin PHPManagerSnapin

New-PHPVersion -ScriptProcessor "$env:ProgramFiles\php8.3\php-cgi.exe" -SiteName "Passwork Web Site" -VirtualPath "/"

Activate PHP extensions for the Passwork website:

$extensions = @(
"php_curl.dll",
"php_gd.dll",
"php_gettext.dll",
"php_intl.dll",
"php_ldap.dll",
"php_mbstring.dll",
"php_mongodb.dll",
"php_mysqli.dll",
"php_openssl.dll",
"php_pdo_pgsql.dll",
"php_pdo_sqlite.dll",
"php_pgsql.dll",
"php_soap.dll",
"php_zip.dll",
"php_fileinfo.dll"
)

foreach ($extension in $extensions) {
Write-Host "PHP extension activated: $extension"
Set-PHPExtension -Name $extension -Status Enabled -SiteName "Passwork Web Site" -VirtualPath "/"
}

Activate additional PHP methods for the Passwork website:

$phpVersion=(Get-PHPConfiguration -SiteName "Passwork Web Site" -VirtualPath "/").Version
Set-WebConfigurationProperty -PSPath "IIS:\Sites\Passwork Web Site" -Filter "system.webServer/handlers/add[@name='php-$phpVersion']" -Name "verb" -Value "GET,HEAD,POST,PUT,DELETE,PATCH"

Delete the temporary directory containing the version 7 Passwork archive:

Remove-Item -Path "$env:WinDir\Temp\update_passwork" -Recurse -Force

Set permissions for the physical Passwork location:

Invoke-Expression "icacls '$env:SystemDrive\inetpub\wwwroot' /grant 'IIS_IUSRS:(OI)(CI)`M'"
Invoke-Expression "icacls '$env:SystemDrive\inetpub\wwwroot' /grant 'Users:(OI)(CI)`M'"
Invoke-Expression "icacls '$env:SystemDrive\inetpub\wwwroot' /grant 'IUSR:(OI)(CI)`M'"