Scripts/CreateDatasource2.ps1
#-------------------------------------# # Configuration # #-------------------------------------# # Change these values to suit your datasource # Database server: $server = 'brumd09515rem'; # Datasource description (must be unique): $dsDescription = 'Test06'; # ODBC name (I always make the ds name and odbc name match) $dsOdbcName = 'Test06'; # Database username: $dsDBUsername = 'sa'; # Database user password: # If you want the script to prompt for the password, do not change anything. # Otherwise, use the commented-out method instead: $dsDBPassword = Read-Host -Prompt "Enter database password" -AsSecureString #$dsDBPassword = ConvertTo-SecureString "your_db_password" -AsPlainText -Force $dsDBPasswordText = ConvertFrom-SecureString $dsDBPassword # ProjectWise administrator username (to be created): $adminUsername = 'pwadmin'; # ProjectWise administrator password (to be created): # If you want the script to prompt for the password, do not change anything. # Otherwise, use the commented-out method instead: $adminPassword = Read-Host -Prompt "Enter ProjectWise admin user password (to be used later on)" -AsSecureString #$adminPassword = ConvertTo-SecureString "admin" -AsPlainText -Force # ProjectWise storage name (must be unique in datasource): $storageName = 'Storage01' # ProjectWise storage host: $storageHost = 'brumd09515rem'; # ProjectWise storage description (must be unique): $storageDescription = 'ProjectWise Storage'; # Path to ProjectWise storage (must not exit - do not create this folder manually, doing so will break the script): $storagePath = ("c:\pwstore\" + $dsDescription + "_" + $storageName) #-------------------------------------# # END Configuration # #-------------------------------------# #See CreateODBC64.ps1 to create a new ODBC Connection. Needs to be run in 64-bit PowerShell. # Continue this script if there are any errors $ErrorActionPreference = 'Continue' # Write out all debug and verbose messages $DebugPreference = 'Continue' $VerbosePreference = 'Continue' # This script must be run as Administrator $windowsIdentity = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()) if (!$windowsIdentity.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { throw 'Insufficient privileges. This script must be run as Administrator.' } # Create datasource New-PWDatasource -DatasourceName $dsDescription -OdbcName $dsOdbcName -DatabaseUserName $dsDBUsername -DatabasePassword $dsDBPassword -AdminUserName $adminUsername -AdminPassword $adminPassword -StorageHost $storageHost -StoragePath $storagePath -LoginSSO -AdminGroupName Administrator -RestrictedAdminGroupName 'Restricted Administrators' -StorageName $storageName -KeepOpenConnection Get-PWUsersByMatch | Get-PWUserWorkingDirectory Get-PWUsersByMatch $adminUsername | Set-PWUserWorkingDirectory "c:\pwwork\$dsOdbcName\$adminUsername" Get-PWUsersByMatch | Get-PWUserWorkingDirectory |