Jump to content

ChrisMiles

Members
  • Posts

    410
  • Joined

  • Last visited

Everything posted by ChrisMiles

  1. You're code is a bit wrong. The Ifs arent encased properly so the messages will print for every verb and the Next is in the wrong place: Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace("C:\Windows\") Set objFolderItem = objFolder.ParseName("Notepad.exe") Set colVerbs = objFolderItem.Verbs For Each objVerb in colVerbs If Replace(objVerb.name, "&", "") = "Pin to Start" Then objVerb.DoIt Wscript.Echo("Added shortcut to Start Screen") End If If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt Wscript.Echo("Added shortcut to Taskbar") End If Next
  2. Powershell is object oriented, it doesnt deal with strings of data like that, you must save your information into an object as below. I also rewrote your function, removing unnecissary code and adding proper error checking. function New-CheckSQLDatabaseResult() { param ($Server, $Database, $Result) $checkSQLDatabaseResult = new-object PSObject $checkSQLDatabaseResult | add-member -type NoteProperty -Name Server -Value $Server $checkSQLDatabaseResult | add-member -type NoteProperty -Name Database -Value $Database $checkSQLDatabaseResult | add-member -type NoteProperty -Name Result -Value $Result return $checkSQLDatabaseResult } function CheckSQLServers { param ($serverNames) $results = @() foreach ($serverName in $serverNames) { $error.Clear() $server = $null $server = New-Object Microsoft.SqlServer.Management.Smo.Server $dbServer $databases = $server.Databases if ($error.Count -gt 0) { $results += New-CheckSQLDatabaseResult $serverName "" "ConnectFail" continue; } foreach ($database in $databases) { $sqlConnection = New-Object System.Data.SqlClient.SqlConnection "Server=$serverName;Database=$($database.Name);Integrated Security=True" $sqlCmd = $sqlConnection.CreateCommand() $sqlCmd.CommandText = "SELECT * FROM sysobjects WHERE type = 'U'" $sqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter $sqlAdapter.SelectCommand = $sqlCmd $dataSet = New-Object System.Data.DataSet $sqlAdapter.Fill($dataSet) $sqlConnection.Close() if ($dataSet.Tables.Count -eq 0) { $results += New-CheckSQLDatabaseResult $serverName $database.Name "QueryFail" } } } return $results } CheckSQLServers @("testsql1", "testsql2", "testsql3") | ConvertTo-Html | Set-Content test.html
  3. I'd say you might want to check your default profile. Make sure you havent deleted the empty folders from your default profile, they are required for folder redirection to work properly.
  4. I tried that too, but you cant do it. The free version is deliberately locked down to prevent silent or automated installs so you have to buy their educational version that comes as an msi.
  5. Really its probably better to use a single server. File Services are not going to max out on memory or CPU power, its going to only be limited by your storage. I'd say divide the shares up on different servers only if the data is held on different arrays and it's likely that one or more arrays could be maxed out during peak usage.
  6. Well since you havn't give much information really, making the following assumptions about your network config, it should just work: 1. Your moodle is hosted locally. 2. Content filtering is done on your gateway, proxy server or further downstream. 3. Your clients are configured to bypass any proxy for local addresses. If it doesnt work with that setup, I'd assume you are accessing it using the external FQDN. I'd suggest in that case, creating a local DNS zone to override the public IPs, forwarding the names to the local IPs instead.
  7. Computer Configuration > Policies > Administrative Templates > System > User Profiles > Delete cached copies of roaming profiles If your profiles are not roaming this will not work though, obviously.
  8. That policy only applies on computer startup and only to profiles that have not been used for the length of time you specify. If they are used periodically they will not be deleted. Equally, if the devices are not rebooted they will not be deleted. Instead I recommend the group policy to prevent student computers from retaining local profile copies at all.
  9. OK stupid problem, in a batch file you have to escape the variables like this: for /f %%a in ('GetADAttributes.exe givenName') do for /f %%b in ('GetADAttributes.exe sn') do mkdir "C:\%%b, %%a"
  10. OK it doesnt work for me in a batch file either.... let me look at it.
  11. Does it create a folder at all? Can you paste your script exactly as is?
  12. If i copy and past that into a command prompt exactly as is it work fine, creating a folder in my C drive called "Miles, Chris".
  13. Ok Plan B.... This application will read attributes from the current user context... Use it like this to create your folder... for /f %a in ('GetADAttributes.exe givenName') do for /f %b in ('GetADAttributes.exe sn') do mkdir "C:\%b, %a" GetADAttributes.zip
  14. Thats not going to work, im pretty sure login scripts run after all the stuff. Let me think about it...
  15. Run it from a dedicated login script, but how you manage the execution order, I'm not too sure.
  16. Calling the application from VBscript isn't going to work, as I edited above, command prompts and applications don't pick up changes to environment variables until they are restarted. Since you said you didn't want to use a script, i didn't envisage using the application in that way. You need to run the program independently to set the variables. Can you clarify what you are trying to do? When and how are you trying to use a folder path with environment variables?
  17. I found this quite interesting so I looked into it and ended up writing this program. I've attached it here for you to use. You can run it on logon script or from group policy to map Active Directory attributes to environment variables. You must run it under the user's context as it uses the current context to get the attributes and uses user environment variables. You can run it like this: adtoenv.exe FORENAME=givenName SURNAME=sn Will work with any AD attribute really, although some values are not human readable. Edit: Requires .NET Framework 4 Client Profile, source available on request. Edit 2: Bear in mind while testing, that command prompts don't pick up external changes to env variables until they are closed and reopened, got caught by this when debugging. ADtoEnv.zip
  18. I think you can click the username to change it, however, you can easily do it from you desk with a "logoff * /server:" command.
  19. If you activate the computer against a KMS server you wont get a limit on the number of syspreps.
  20. Disabling Receive-Side Scaling and Receive Windows Auto-Tuning have always fixed issues like this for me in the past, its worth a shot. Run on the r2 server: netsh interface tcp set global rss=disabled autotuninglevel=disabled and reboot.
  21. GPP doesn't handle printer drivers at all. If your printers are shared on a print server, Windows will download drivers only when the one on the server is newer or when there isn't a local driver available. This behaviour is the same no matter how you connect to shared printers. Are you sure that it's printers causing the delay? Personally, I gave up using GPP for printers ages ago because of huge problems with HP drivers, we now use a client application to deploy printers which is nice because it doesn't slow the login down and allows for real-time updates to peoples printer allocations. Edit: Just a random thought but might be worth checking that Windows isnt checking windows updates for a driver first.
  22. Those passwords are easily decoded, in case theyre important, you may want to remove them
  23. I've done something similar to this recently. Assuming that mail coming in from outside to one of the servers, its easy enough to accomplish with an Internal Relay domain and Send Connectors for each server (on each of the servers). With 3 servers you can create a primary and secondary delivery loop, in case one server is taken down. So... On server1 configure a connector for server2 with a cost of 1 and a connector for server 3 with a cost of 2. On server2 configure a connector for server3 with a cost of 1 and a connector for server 1 with a cost of 2. On server3 configure a connector for server1 with a cost of 1 and a connector for server 2 with a cost of 2. This setup will obviously mean that some internal mails must pass through all 3 servers, if for example you sent a mail from server1 to server3 it would go through server2, but this shouldnt be a problem. E-mails sent to addresses that none of the servers recognise will go round in a loop a couple of times and then return to sender with a mail loop error, but thats about the only downside (its a non-issue for me).
  24. /sarcasm? No it doesnt, because Windows services are supposed to use the Windows Event Log to log day-to-day activity not flat text files. Generally a windows installer will write to a log file as a one off and most services use the event log. There are always exceptions, but thats the fault of the service, not Windows.
  25. Yeah, its possible, I wrote a powershell script to auto generate ad users from SIMS and as part of that we record admission numbers and upns into fields in AD. We record the admission numbers against AD users at creation because there is no other reliable way of linking an AD user to a student in SIMS. This will be your problem with doing it automatically. How do you find the right student in AD to record the number against? Use their name to calculate a username? Surely you have name clashes which forced you to use a slightly non standard format, so that will cause problems. I suggest you do it manually once as you suggest and then ensure that you record the number when you create any additional users.
×
×
  • Create New...