If you run it as I posted it above, you don’t need to manually create the email address by adding $alias and $domain. $_.PrimarySmtpAddress is already a property of the mailbox and should be the user’s email address. Sorry if I’m not clear on what you’re trying to accomplish.
As far as your second question, something like this might work (although I’m sure there’s a better way of doing it):
$File = 'C:\Program Files\autodesk\autocad map 3d 2012\acdgnls.dbx’ $FileVersionInfo = (Get-Command $File).FileVersionInfo [int]$CurrentVersion = "$($FileVersionInfo.FileMajorPart).$($FileVersionInfo.FileMinorPart)" if ($CurrentVersion -lt 18.2) { Write-Host 'Renaming File' ren $File $File.Replace('acdgnls.dbx’,'acdgnls.bak’) Write-Host 'Copying File' copy '<source>' '<target>' } else { return }
Edited – accidentally renamed file to .exe and not .bak when I first posted.
Thanks again for the help with the scripts. I need to add some more logic to the second script that you provided about file version checking. So the script worked perfectly, but what i found out is that i am missing autocad service packs possibly on machines that need to be deployed before running the original script you provided. So i need to have it check for which version the acad.exe file is under: ‘C:\Program Files\autodesk\autocad map 3d 2012\acad.exe’
i have three version to check:
autocad – no service pack installed – version: R18.2.51.0.0
autocad – service pack 1 installed – version: R18.2.107.0.0
autocad – service pack 2 installed – version: R18.2.205.0.0
Service Pack 1 & 2 are .msp files that need to be installed. Can i just run msiexec within the powershell script?
msiexec.exe /update “\\remoteserver\VOL2\Program Files\AutoCAD Map 3D 2012\updates\map2012_x64_sp1.msp” /l*v “%WINDIR%\Temp\map2012_x64_sp1.log”
msiexec.exe /update “\\remoteserver\VOL2\Program Files\AutoCAD Map 3D 2012\updates\autocadmap3d2012_sp2_x64.msp” /l*v “%WINDIR%\Temp\autocadmap3d2012_sp2_x64.log”
Logic:
file check acad.exe. if <= version: R18.2.51.0.0 then apply SP1 & SP2 then go to file check acdgnls.dbx file check script
file check acad.exe. if > version: R18.2.51.0.0 but <= version: R18.2.107.0.0 then apply SP2 then go to file check acdgnls.dbx file check script
file check acad.exe. if > version: R18.2.107.0.0 but <= version: R18.2.205.0.0 then apply no service packs then go to file check acdgnls.dbx file check script