#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # # Script Name: QlikSenseLockOut.ps1 # Description: This script will create a local user then elevate that Users' permissions in Qlik Sense to # work around a bad LDAP filter # Version Date Author Change Notes # 0.1 2017-08-24 Levi Turner Initial Version #---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- $startupLocation = Get-Location $machineName = hostname $machineName = $machineName.ToUpper() # Creating Local User echo "Creating Local User" echo "Username: QlikSenseBackup" echo "Password: Password123!" echo "Press any key to continue..." NET USER QlikSenseBackup "Password123!" /ADD $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") # User Accesses Qlik Sense to create user record echo "Login to the QMC or Hub as .\QlikSenseBackup" echo "Press any key after doing so..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") echo "Please select the main installation folder for Qlik Sense Server." echo "Example: C:\Program Files\Qlik\Sense" echo "Press any key to continue..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Add-Type -AssemblyName System.Windows.Forms $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog $FolderBrowser.Description = "Please select your Qlik Sense installation folder..." $FolderBrowser.RootFolder = "MyComputer" [void]$FolderBrowser.ShowDialog() $installPath = $FolderBrowser.SelectedPath clear # Building the query "UPDATE $([char]34)Users$([char]34) SET $([char]34)RolesString$([char]34)=$([char]39)RootAdmin$([char]39) WHERE ($([char]34)UserId$([char]34)=$([char]39)qliksensebackup$([char]39) and $([char]34)UserDirectory$([char]34)=$([char]39)$machineName$([char]39));" | set-content elevate.sql -Encoding Ascii #Stopping Services echo "Qlik Sense Services will now stop" echo "Press any key to continue..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") net stop "Qlik Sense Engine Service" net stop "Qlik Sense Printing Service" net stop "Qlik Sense Proxy Service" net stop "Qlik Sense Scheduler Service" net stop "Qlik Sense Repository Service" net stop "Qlik Sense Service Dispatcher" #Query execution echo "The program will prompt you for the Repository password if needed. Starting query execution..." sleep 2 cd $installPath\Repository\PostgreSQL\9.*\bin .\psql.exe -U postgres -p 4432 -d QSR -e -f $startupLocation\elevate.sql #Starting Services echo "Qlik Sense Services will now start" echo "Press any key to continue..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") net start "Qlik Sense Service Dispatcher" TIMEOUT 2 net start "Qlik Sense Repository Service" TIMEOUT 2 net start "Qlik Sense Engine Service" TIMEOUT 2 net start "Qlik Sense Printing Service" TIMEOUT 2 net start "Qlik Sense Proxy Service" TIMEOUT 2 net start "Qlik Sense Scheduler Service"