Jump to content

Recommended Posts

Posted

I've put together a PowerShell script which is basically the procedure suggested in TEC1395295 minus the reboot or SH restart as you don't need this. Packages will assign fine after simply renaming the file.

 

The script prompts for a station name and then on this, removes the corrupt file, removes any .old files that have no content and renames the most recent good one to "RM.Networks.Comms.Data.Dal.dll.config". It also opens the Data Access Layer folder on the remote machine should you want to review the results however, this

can be commented out in the script if you don't want it appearing.

 

You will need to run the following command on your computer before the script will work as default Windows behaviour is to restrict PowerShell scripts.

set-executionpolicy remotesigned

 

Copy the below script into notepad, save and rename the extension to .ps1:

# Deletes corrupt .config file and renames most recently archived (.old) to "RM.Networks.Comms.Data.Dal.dll.config"

# Prompts for computer name and sets as a variable 
$ComputerName = read-host "Computer Name"

# Sets variable for DAL folder on remote machine
$dal = "\\$ComputerName\c$\Program Files\RM\Connect\Data Access Layer"

# Sets variable for .old files
$oldfiles = "\\$ComputerName\c$\Program Files\RM\Connect\Data Access Layer\*.old"

# Opens Data Access Layer folder on target machine for review purposes.
# Comment this out if you don't want the window opening
explorer $dal

# Removes Corrupt/blank .config file
remove-Item $dal\RM.Networks.Comms.Data.Dal.dll.config

# Removes all .old files with a size of 0 bytes as previous ones can still be corrupt
get-childItem $oldfiles | where {$_.length -eq 0} | remove-Item 

# Sorts .old files by age and renames the most recent to "RM.Networks.Comms.Data.Dal.dll.config"
get-childItem $oldfiles | sort LastWriteTime | select -last 1 | rename-Item -newname RM.Networks.Comms.Data.Dal.dll.config

 

I'm sure there are shortcuts that can be made in the code so feel free to modify it and post back :D

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...