Close Out of Power Broker Software for Update or Maintenance

RE:  Close Out of Power Broker Software for Update or Maintenance on a Domain:

This document was designed for a more technical way of locking Power Broker down for maintenance or  update on a Domain.  If the customer has multiple copies of Power Broker, this will close them all so please be aware.

If you plan on doing an update or maintenance at 6PM in this example, please ensure that you email all users to exit Power Broker well in advance so that you can ensure that everyone is out of the software.

The PowerTools ‘Lock PB4 for Maintenance’ is the first place to start.  This ensures that once Power Broker is locked so that further staff will not be able to log in.

Once your project is completed, please ensure that you ‘Unlock PB4 for Full Access’ .

The next few steps were made to ensure that can not only force close users out of Power Broker but to also close any trapped files left open in Computer Management, Shared Folders, Open files on a Domain.  Once you follow these next few steps, right after you use PowerTools to block users, you should be able to go to C:\TaskScheduler\ and double click CloseAllPB.CMD and it should run through the following scripts that you have created.

STEP 1

Creating a list of your computer names in PowerShell connected as Administrator on your Server

Open PowerShell and place this code in Powershell in the bottom command window.  It will give you the names of the computers that you will need to add to the next step.

Get-ADComputer -Filter * -properties *|select name, DNSHostname, OperatingSystem, LastLogonDate
Sample:

Screen capture the list of computers.

Exit PowerShell .

STEP 2

Creating a .CMD file with some commands that will close out Power Broker.

On the C:\TaskScheduler folder of the server, create a .TXT file called CloseAllPB.TXT .

Copy these next five lines to the .TXT file.

taskkill /s COMPUTERNAME /im brow.exe
taskkill /s COMPUTERNAME /im brow.exe
taskkill /s COMPUTERNAME /im brow.exe
taskkill /s COMPUTERNAME /im brow.exe
taskkill /s COMPUTERNAME /im brow.exe

Copy and paste it again the number of computers you have in your list.

Replace COMPUTERNAME with the actual name of the computer names you have on your screen capture.

Please take note that some of the items may be a printer or some other hardware device.  You do not need to add those.

Add the following line to the end of the script:

PowerShell.exe Invoke-Command -ScriptBlock { “C:\TaskScheduler\CloseAllPBStuff.ps1”}

Save the document C:\TaskScheduler\CloseAllPB.TXT once completed.

In Windows Explorer/File Manager, ensure that you are displaying files extensions ( Options, View, Hide Extensions for know File types should be blank, if not uncheck, uncheck and apply to all folders, and then yes and then OK) and change CloseAllPB.TXT to CloseAllPB.CMD .  If it gives you the warning you are changing the file extension, that’s fine, click ok or accept.

STEP 3

Creating  PowerShell script that will close files out that maybe left open

Open PowerShell and copy the next set of lines and past into the top screen of PowerShell.

IMPORTANT:  Where you see set-location and the server share, please change this to where your data is, and not the mapped drive.
Y:\Storage\DataQ\BRO is just an example.  There are 5 changes to be made by you.

set-location Y:\Storage\DataQ\BRO

Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.EXE” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.DLL” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.DBF” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.FPT” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.CDX” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.PNG” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.PS1” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.CMD” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.BAT” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.TXT” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.REG” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.RAR” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.PB4” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.MSG” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.DOCX” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.PRG” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.APP” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.XLSX” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.CSV” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.XLS” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.MEM” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.IDX” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.ICO” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.FPW” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.INI” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.ZIP” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.BMP” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.BAK” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.PDF” | Close-SmbOpenFile -Force

set-location Y:\Storage\DataQ\BRO\ad

Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.EXE” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.DAT” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.IDX” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.CDX” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.DBF” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.FPT” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.TXT” | Close-SmbOpenFile -Force

set-location Y:\Storage\DataQ\BRO\bmps

Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.GIF” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.EXE” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.BMP” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.ICO” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.JPG” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.MSK” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.PNG” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.LOG” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.WAV” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.XCF” | Close-SmbOpenFile -Force

set-location Y:\Storage\DataQ\BRO\rptw

Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.TMP” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.LBA” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.LBT” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.LBX” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.FRA” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.FRT” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.FRX” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.PDF” | Close-SmbOpenFile -Force

set-location Y:\Storage\DataQ\BRO\rr

Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.TXT” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.CDX” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.DBF” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.FPT” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.TXT” | Close-SmbOpenFile -Force

set-location Y:\Storage\DataQ\BRO\word97

Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.DOC” | Close-SmbOpenFile -Force
Get-SmbOpenFile | Where-Object -Property ShareRelativePath -Match “\.DOCX” | Close-SmbOpenFile -Force

Save this file in C:\TaskScheduler on the server and name it CloseAllPBStuff.ps1

Exit PowerShell

Summary:  Now that have completed all the steps, the next time you have maintenance or an update, you would:
A) Run Powertools as mentioned and Lock Users
B) On the server, open Windows Explorer/File Explorer, and run C:\TaskSchedulerClossAllPB.cmd
C) Run the maintenance or the update
D) Once completed, Run PowerTools and Unlock Users.

Revised:  June 16/2022