Link to home
Start Free TrialLog in
Avatar of ITMcmcpa
ITMcmcpaFlag for United States of America

asked on

Script to replace Outlook Signature graphics

Hello,

I need a script that will look for a specific file in subfolders based on name and size and replace it with another file.

Here is the task:

We have to change a graphic on our Firm's Outlook signature block.  I want to run a script on each computer (maybe via login script) that will search all signature folders and it's subfolders under %appdata%/Microsoft/Signatures and replace the file image003.gif that has a size of 2470 bytes.  We will replace it with another file called image003.gif copied from another network location.

Thanks!
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

Try this - http://www.myitforum.com/articles/40/view.asp?id=9571
This script will find a file on C drive (or whatever drive we choose), rename it and replace it with another file. The new file should be in the same directory where you execute your powershell script.


#Because of CIM_DataFile, split File Name and Extension into two variables
$strFileName = "Foo"
$strFileExt = "doc"
$strNewFileName = "Foo2.doc"

$colFiles = get-wmiobject -query "Select * from CIM_Datafile where FileName = '$strFileName'and extension = '$strFileExt' and drive ='C:'"
Foreach ($objfile in $colfiles)
{
Ren $objfile.name -newname ($objfile.filename +".bak")
copy-item $strNewFileName -destination ($objfile.drives + $objfile.path)
}
You might need to copy the replacement file to the local drive to use the above script.
http://www.remotedatabackups.com/kb/kb.cfm?id=63
Avatar of ITMcmcpa

ASKER

Unfortunately this will not work for my needs.
ASKER CERTIFIED SOLUTION
Avatar of ITMcmcpa
ITMcmcpa
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial