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
Advertisements

Set Internet Explorer As Default Browser Through Registry

Djseppie'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

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsUrlAssociationshttpUserChoice]
“Progid”=”IE.HTTP”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsUrlAssociationshttpsUserChoice]
“Progid”=”IE.HTTPS”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsUrlAssociationsftpUserChoice]
“Progid”=”IE.FTP”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.htmUserChoice]
“Progid”=”IE.AssocFile.HTM”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.htmlUserChoice]
“Progid”=”IE.AssocFile.HTM”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.mhtUserChoice]
“Progid”=”IE.AssocFile.MHT”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.mhtmlUserChoice]
“Progid”=”IE.AssocFile.MHT”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.partialUserChoice]
“Progid”=”IE.AssocFile.PARTIAL”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.svgUserChoice]
“Progid”=”IE.AssocFile.SVG”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.urlUserChoice]
“Progid”=”IE.AssocFile.URL”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.websiteUserChoice]
“Progid”=”IE.AssocFile.WEBSITE”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.xhtUserChoice]
“Progid”=”IE.AssocFile.XHT”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.xhtmlUserChoice]
“Progid”=”IE.AssocFile.XHT”

[HKEY_CURRENT_USERSoftwareClientsStartMenuInternet]
@=”IEXPLORE.EXE”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsMIMEAssociationstext/htmlUserChoice]
“Progid”=”IE.text/html”

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsMIMEAssociationsmessage/rfc822UserChoice]
“Progid”=”IE.message/rfc822”

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.

hipster-dog-listening-to-headphones-poster

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.