Move all files with same prefix using Powershell

We have an application that we run on a server that generates a set of logs that all have the same prefix, for example, abc123_johnson.log, or abc123_smith.log. Every user has a corresponding log with there name preceded by the same prefix. Here is a simple way to recursively search that directory for all files with that prefix and move them.



# This script is to manage the abc123_username logs on the Server "A", to keep thirty days of logs, then
# move them off to a share on the Server "B", then delete them. (The logs take too much space on the Server "A".)
# The move cmdlet will automatically replace the old files on Server "B" so no need to delete them

$username = "usernamehere"
$password = "passwordhere"
$secureStringPwd = $password | ConvertTo-SecureString -AsPlainText -Force 
$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user, $secureStringPwd

# Move the logs from the last thirty days from Server "A" to Server "B" 
Get-Childitem \\SERVERNAME_A\SUBFOLDER\SUBFOLDER -recurse -include abc123_* | Move-Item -force -destination \\SERVER_B\SUBFOLDER

# Logging of some kind below to indicate success.
Remove-Item -Path D:\SERVERLOGSMOVE\Serverlogsmove.txt -force
New-Item D:\SERVERLOGSMOVE\Serverlogsmove.txt -type file

Set Internet Explorer As Default Browser Through Registry

Seppie's Blog

The following registry entries must all be changed in order to set Internet Explorer as the default browser and pass the ‘Would you like to set Internet Explorer as default browser’ popup.

Windows Registry Editor Version 5.00

















View original post

Dealing with MSI Restart Manager, when deploying an MSI silently.

What do you do when an MSI install is interrupted by a Restart Manager prompt?  This is where you see something like this: “Close x program to complete install, or restart is needed”

This is an issue, because by default with a /qb /qn or any silent switch, the default UI option is to close the application. This is especially problematic when it tries to close Windows Explorer, so the user will see a blank black screen with no icons, and the only way to get explorer back is to call Task Manager and create a new Explorer process.

Editing the MSI, or creating a transform that sets the MSIRESTARTMANAGERCONTROL property to Disable, Disableshutdown, 0 etc… will usually work. This should eliminate the restart / or close application option from being presented, and you can handle the reboot in your deployment by SCCM.

However….. I came across an MSI that need to be beaten into submission. The MSIRESTARTMANAGERCONTROL modifications are ignored by the Nuance PDF Converter 8.2, for Windows 7. Solution was to remove the RMFilesinuse dialogue in the MST, using Installshield (or orca). Now the MSI/MST runs with a silent switch with no interruptions by the Restart Manager prompt.


WMIC Commands

Very useful when all other silent uninstall options don’t work. Silent or unattended uninstallation can be tricky at times. Especially if the there is no msi guid in the registry, or recording an answer file fails. Windows, even Windows 7 has a built in utility, WMIC. Command is ……, and everything with that product name will get silently removed.