Link to home
Start Free TrialLog in
Avatar of ihotdesk
ihotdeskFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Copying NK2 files from TS Profiles to new TS .V2 Profile.

Hi there,

I am wanting to create a script to copy users NK2 file from their old profile to their new one when logged into the new TS server. The old TS server was a 2003 Server (hence old profiles...documents and settings)

The new TS server is a 2008 server, therefore new V2 profile. I have tried using this script:


Dim WshShell : Set WshShell = Wscript.CreateObject("Wscript.Shell")
Dim fso : Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
Dim oNet : Set oNet = Wscript.CreateObject("Wscript.Network")
Dim WshEnv : Set WshEnv = WshShell.Environment("Process")
SysDrive = WshEnv("%SystemDrive%")

sFolder = "\\serverdc01\tsprofiles$" & oNet.Username & "\Application Data\Microsoft\Outlook" 'folder to look in
dFolder = SysDrive & "\users\" & oNet.Username & "\appdata\roaming\microsoft\outlook"
IF fso.FolderExists(sFolder) Then


Set oFolder = fso.GetFolder(sFolder)
Set oFiles = oFolder.Files
FOR Each oFile In oFiles
ext = fso.GetExtensionName(oFile)
' check if characters in file extension is "NK2"
IF UCase(ext) = "NK2" Then
Wscript.Echo "NK2 file exists" 'Backup the file NK2 to a server.
Wscript.Echo ext

Set oFolder = fso.CreateFolder(dfolder)
fso.copyfile ofile.path, dfolder
End If
Next
End If


But it doesnt seem to work. I'm not very good at vbscripts so thats probably why! Can anyone advise on this or advise an easy way to do this. They really need the nk2 copied from their old profile location to their new profile. One thing I did notice was that on the old server the profile folders are all username.domainname

e.g.   jsoap.example   (domain being: example)

Anyone have any helpful tips for me to try? Thanks in advance!
Avatar of Steve
Steve
Flag of United Kingdom of Great Britain and Northern Ireland image

Does it copy a file across or fail?

Whats this bit for?

t oFolder = fso.GetFolder(sFolder)
Set oFiles = oFolder.Files
FOR Each oFile In oFiles
ext = fso.GetExtensionName(oFile)
' check if characters in file extension is "NK2"
IF UCase(ext) = "NK2" Then
Wscript.Echo "NK2 file exists" 'Backup the file NK2 to a server.
Wscript.Echo ext

Cant you just  go straight ahead and copy the file, as its always called outlook.nk2 anyway?
Also have you checked the users have access to the \\serverdc01\tsprofiles$ share from the new server?
ASKER CERTIFIED SOLUTION
Avatar of MaxSoullard
MaxSoullard
Flag of United Kingdom of Great Britain and Northern Ireland 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
Avatar of kingslandcomputers
kingslandcomputers

wow, thanks for this. just what i needed as well.

Now lets see if i can modify it to copy the IE favourites folder from old to new...

Jono.
were you able to figure out how to copy favorites?