Monthly Archives: February 2012

Finding the logon scripts

What logon scripts are in your environment “`nMicrosoft” Get-ADUser -LDAPFilter “(&(objectclass=user)(objectcategory=user)(scriptpath=*))” -Properties *| Format-Table Name, DistinguishedName, ScriptPath -AutoSize “`nAD provider” Get-ChildItem -Filter “(&(objectclass=user)(objectcategory=user)(scriptpath=*))” ` -Path Ad:\”DC=Manticore,DC=org” -Recurse | foreach { $user = [adsi]”LDAP://$($_.DistinguishedName)” $user | select @{N=”Name”; E={$_.name}}, @{N=”DistinguishedName”; E={$_.distinguishedname}}, … Continue reading

Posted in PowerShell and Active Directory | Leave a comment

Set user’s logon script

Staying on the profile tab we can also set a logon script $ou = “OU=BlogTests,DC=Manticore,DC=org” “`nMicrosoft” $name = “UserA” Get-ADUser -Identity $name | Set-ADUser -ScriptPath “ls1.cmd” “`nAD provider” $name = “UserB” $dn = “cn=$name,$ou” Set-ItemProperty -Path AD:\$dn -Name scriptpath -Value … Continue reading

Posted in PowerShell and Active Directory | Leave a comment

Finding the users home drives

To display the home drive information for your users “`nMicrosoft” Get-ADUser -LDAPFilter “(&(objectclass=user)(objectcategory=user)(homeDirectory=*))” -Properties *| Format-Table Name, DistinguishedName, HomeDirectory, HomeDrive -AutoSize “`nAD provider” Get-ChildItem -Filter “(&(objectclass=user)(objectcategory=user)(homeDirectory=*))” ` -Path Ad:\”DC=Manticore,DC=org” -Recurse | foreach { $user = [adsi]”LDAP://$($_.DistinguishedName)” $user | select @{N=”Name”; … Continue reading

Posted in PowerShell and Active Directory | Leave a comment

Setting a users home directory

One task when creating a new user is to set their home directory. This information is on the Profile tab in the lower box. In the GUI we would use the Connect radio button, select a drive letter and supply … Continue reading

Posted in PowerShell and Active Directory | 5 Comments

UK PowerShell group–February 2012 recording

The recording, slides and demo scripts from tonight’s PowerShell and SQL Server session are available as a single zip file for download from https://skydrive.live.com/#cid=43CFA46A74CF3E96&id=43CFA46A74CF3E96%212943 The file is created with jzip but any zip handling program should be able to unzip … Continue reading

Posted in PowerShell and SQL Server, PowerShell User Group | Leave a comment

Group’s displayname

A question on the forum asked about setting the value for a group’s displayname attribute.  When you first create a group using any of the techniques we have seen earlier the displayname property is not set.  You can set it … Continue reading

Posted in PowerShell and Active Directory | Leave a comment

Connecting via SMO to a named instance

A question came up in tonight’s User group session regarding connecting to SQL server instances using SMO If you have just a default instance – just give the server name $server = New-Object -TypeName “Microsoft.SqlServer.Management.Smo.Server” -ArgumentList “W08R2SQl12” If you have … Continue reading

Posted in PowerShell and SQL Server | 1 Comment

Remove all members from a group

Do you need to remove all members from a group $ou = “OU=BlogTests,DC=Manticore,DC=org” “`nMicrosoft” $group = “GroupUnvlSecA” Get-ADGroupMember -Identity $group | Remove-ADPrincipalGroupMembership -MemberOf $group -Confirm:$false “`nAD provider” $group = “GroupUnvlSecB” $ou = “OU=TestGroups,DC=Manticore,DC=org” $members = @() Set-ItemProperty -Path ad:\”cn=$group,$ou” -Name … Continue reading

Posted in PowerShell and Active Directory | Leave a comment

February UG meeting–Final reminder

  The UK PowerShell group presents a Live Meeting tomorrow on using PowerShell with SQL Server Details from http://msmvps.com/blogs/richardsiddaway/archive/2012/02/09/february-powershell-group-meeting-sql-server-and-powershell.aspx

Posted in PowerShell and SQL Server, PowerShell User Group | Leave a comment

Copy group membership

We may need to copy the members of one group into a second In these examples I’m copying the membership of a Universal group into a Domain Local group.  That’s just because I have those groups available. You can copy … Continue reading

Posted in PowerShell and Active Directory | Leave a comment