header image

Archive for February, 2012

Finding the logon scripts

Posted by: | February 29, 2012 | No Comment |

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}}, @{N="LogonScript"; E={$_.scriptpath}} } | Format-Table -AutoSize "`nQuest" Get-QADUser -LDAPFilter "(&(objectclass=user)(objectcategory=user)(scriptpath=*))" -IncludeAllProperties | Format-Table Name, DN, […]

under: PowerShell and Active Directory

Set user’s logon script

Posted by: | February 29, 2012 | No Comment |

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 "ls1.cmd" -Force "`nQuest" $name = "UserC" Get-QADUser -Identity $name | Set-QADUser -LogonScript "ls1.cmd" "`nScript" $name […]

under: PowerShell and Active Directory

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"; E={$_.name}}, @{N="DistinguishedName"; E={$_.distinguishedname}}, @{N="HomeDirectory"; E={$_.homeDirectory}}, @{N="HomeDrive"; E={$_.homeDrive}} } | Format-Table -AutoSize "`nQuest" Get-QADUser -LDAPFilter "(&(objectclass=user)(objectcategory=user)(homeDirectory=*))" […]

under: PowerShell and Active 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 the UNC path to a share.  In PowerShell we do this $ou = "OU=BlogTests,DC=Manticore,DC=org" "`nMicrosoft" […]

under: PowerShell and Active Directory

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 it Thank you to the attendees and especially for the questions – I’ve posted the […]

under: PowerShell and SQL Server, PowerShell User Group

Group’s displayname

Posted by: | February 28, 2012 | 1 Comment |

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 like this Get-QADGroup -Identity GroupDmlSecA $group = "GroupDmlSecA" Get-QADGroup -Identity $group Get-QADGroup -Identity $group | […]

under: PowerShell and Active Directory

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 a named instance the give the instance name as well $serverI = New-Object -TypeName […]

under: PowerShell and SQL Server

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 member -Value $members -Force "`nQuest" $group = "GroupUnvlSecC" Get-QADGroupMember -Identity $group | Remove-QADGroupMember -Identity $group […]

under: PowerShell and Active Directory

  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

under: PowerShell and SQL Server, PowerShell User Group

Copy group membership

Posted by: | February 27, 2012 | No Comment |

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 between any two groups but remember that global groups can only contain members from within […]

under: PowerShell and Active Directory

Older Posts »

Categories