Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query profile type...

Status
Not open for further replies.

wibbe

IS-IT--Management
Oct 30, 2002
68
0
0
SE
Hi all,

I have some problems to write a script to find out the current profile type (Local / Roaming or Mandatory).

I can access the object WIN32_LogonSession and this one include the profile type but not the username.
I can access the object WIN32_NetWorkLoginProfile, but this does not include the profile type.

I need this script to verify that the users got the central profile in a large Terminal Server environment.

All help or hints is very welcome!
Thanks.
 
Something like this ?

Code:
Set WshNetwork = CreateObject("Wscript.Network")

If WshNetwork.UserDomain <> WshNetwork.ComputerName Then

	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
	Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkLoginProfile Where Name = '" & WshNetwork.UserDomain & "\\" & WshNetwork.UserName & "'")
	
	For Each objItem In colItems
		strProfile = objItem.Profile
	Next
	strLocalLogon = False
Else
	strLocalLogon = True
	
End If

If strLocalLogon = True Then
	Wscript.echo "Locally logged on user, profile type : Local"

	ElseIf strLocalLogon = False And strProfile = "" Then
		wscript.echo "Domain User " & WshNetwork.UserName & " has a local profile"
		
		Else
		wscript.echo "Domain User " & WshNetwork.UserName & " has a roaming profile"
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top