<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>There are some that call me...Tim</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/tswift/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/tswift/feed.xml</link>
    <description>SDET musings on Server related stuff</description>
    <lastBuildDate>Wed, 17 Apr 2019 04:10:39 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Using SharePoint OM to get the Default URL on a SharePoint Farm</title>
      <link>https://docs.microsoft.com/archive/blogs/tswift/using-sharepoint-om-to-get-the-default-url-on-a-sharepoint-farm</link>
      <pubDate>Wed, 10 Feb 2010 13:33:00 GMT</pubDate>
      <dc:creator><![CDATA[tswift]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/tswift/2010/02/10/using-sharepoint-om-to-get-the-default-url-on-a-sharepoint-farm/</guid>
      <description><![CDATA[How to get the Default port&nbsp;80 URL on a SP Farm using the SP Object Model. This is useful if...]]></description>
      <content:encoded><![CDATA[<P>How to get the Default port&nbsp;80 URL on a SP Farm using the SP Object Model. This is useful if you're trying to run code on a Windows Front End (WFE) but don't know the SP Farm URL</P>
<P>Note that this code MUST run on a SP server front end.</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using Microsoft.SharePoint.Administration;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Check if we are on a SP server farm or not to get default server URL<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPFarm farm = SPFarm.Local;&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (farm != null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Get the collection of all SP Alternate Urls&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPAlternateUrlCollectionManager altUrlCollectionMgr = farm.AlternateUrlCollections;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // iterate thru collections of Urls<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (SPAlternateUrlCollection altColl in altUrlCollectionMgr)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (SPAlternateUrl url in altColl)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // check if url is in Default zone<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P>]]></content:encoded>
    </item>
    <item>
      <title>PowerShell how to get around Active Directory referral errors</title>
      <link>https://docs.microsoft.com/archive/blogs/tswift/powershell-how-to-get-around-active-directory-referral-errors</link>
      <pubDate>Wed, 26 Aug 2009 09:26:00 GMT</pubDate>
      <dc:creator><![CDATA[tswift]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/tswift/2009/08/26/powershell-how-to-get-around-active-directory-referral-errors/</guid>
      <description><![CDATA[If you're getting referral errors from your PowerShell scripts trying to enumerate users the problem...]]></description>
      <content:encoded><![CDATA[<P>If you're getting referral errors from your PowerShell scripts trying to enumerate users the problem is most likely your LDAP search scope. An LDAP&nbsp;referral error occurs when you're searching in a domain that doesn't contain the user you're looking for. For example, if you're looking for user cn=foo,dc=HQ,dc=contoso,dc=com, but your search scope is set to dc=contoso,dc=com, the server may return a referral error. Some LDAP applications can handle referrals but for scripting you may want to try something less complex.</P>
<P>In the below example I contact the AD Global Catalog (GC) for the current domain and search for the AD "mail" attribute. The GC&nbsp;contains limited records of every AD object in the Forest. If I find the object I then&nbsp;get it's Distinguished Name (DN). The DN that returns can be from&nbsp;a domain other than the current domain&nbsp;(ex. cn=foo,dc=HQ,dc=contoso,dc=com). Then I cast the DN to an ADSI object so I can get/update it's properties. This gets you around the referral error!</P>
<P># Contact AD Global Catolog to search for email address<BR>&nbsp;$dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()<BR>&nbsp;$root = [ADSI]"GC://$($dom.Name)"<BR>&nbsp;$search = new-Object System.DirectoryServices.DirectorySearcher($root,"(mail=$stmail)")<BR>&nbsp;$result = $search.FindOne()</P>
<P>&nbsp;if($result -ne $null)<BR>&nbsp;{<BR>&nbsp;&nbsp;$user = $result.GetDirectoryEntry()<BR>&nbsp;&nbsp;#write-host "User: " $user.distinguishedName " found" -ForeGroundColor Green;<BR>&nbsp;<BR>&nbsp;&nbsp;# cast each member as an ADSI object<BR>&nbsp;&nbsp;$user2 = $user.distinguishedName<BR>&nbsp;&nbsp;$adsPath = 'LDAP://' + $user2<BR>&nbsp;&nbsp;$account=[ADSI]$adspath<BR>&nbsp;&nbsp;$account.setinfo()<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;#update all users<BR>&nbsp;&nbsp;$account.put($ManagerURI, $GrooveManager)<BR>&nbsp;&nbsp;$account.setinfo()<BR>&nbsp;&nbsp;write-host "&nbsp;Provisioned account: " $account.distinguishedName " " -ForeGroundColor Green;&nbsp;<BR>&nbsp;&nbsp;$counter++</P>
<P>&nbsp;}<BR>&nbsp;else<BR>&nbsp;{<BR>&nbsp;&nbsp;#$stmail<BR>&nbsp;&nbsp;write-host "&nbsp;Error: Member Email does not exist in Active Directory Global Catalog" -ForeGroundColor Red;<BR>&nbsp;}</P>]]></content:encoded>
    </item>
    <item>
      <title>Getting XML values in PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/tswift/getting-xml-values-in-powershell</link>
      <pubDate>Tue, 25 Aug 2009 17:21:00 GMT</pubDate>
      <dc:creator><![CDATA[tswift]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/tswift/2009/08/25/getting-xml-values-in-powershell/</guid>
      <description><![CDATA[I couldn't believe how easy this was when I finally figured it out...&nbsp;I needed to enumerate all...]]></description>
      <content:encoded><![CDATA[<P>I couldn't believe how easy this was when I finally figured it out...&nbsp;I needed to enumerate all of the email addresses with an &lt;email&gt; tag in an XML file. The only really tricky thing was using the "InnerXML" property</P>
<P>&nbsp;# Create XML document from file<BR>$MemberDoc = [xml](get-content $XMLFile)</P>
<P># Get all of the email addresses in the XML document<BR>$EmailAddresses = $MemberDoc.GetElementsByTagName("Email")</P>
<P>Foreach ($Email in $EmailAddresses){</P>
<P>&nbsp;# Get InnerXML value of Email node and assign it to&nbsp;string<BR>&nbsp;$stmail=$Email.InnerXML</P>
<P>}</P>]]></content:encoded>
    </item>
    <item>
      <title>Powershell: Enumerating a LDAP Group with a large (&gt;1500) number of users</title>
      <link>https://docs.microsoft.com/archive/blogs/tswift/powershell-enumerating-a-ldap-group-with-a-large-1500-number-of-users</link>
      <pubDate>Wed, 29 Apr 2009 11:27:00 GMT</pubDate>
      <dc:creator><![CDATA[tswift]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/tswift/2009/04/29/powershell-enumerating-a-ldap-group-with-a-large-1500-number-of-users/</guid>
      <description><![CDATA[Okay I searched though a lot of PowerShell Blogs for the answer to this but couldn't find a solution...]]></description>
      <content:encoded><![CDATA[<P>Okay I searched though a lot of PowerShell Blogs for the answer to this but couldn't find a solution that really worked. I finally just took the C# solution from a MSDN article (<A href="https://msdn.microsoft.com/en-us/library/ms180907(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/ms180907(VS.85).aspx">https://msdn.microsoft.com/en-us/library/ms180907(VS.85).aspx</A>) and converted it to PowerShell. Hopefully this is helpful to someone!</P>
<P><BR>#&nbsp;$LDAPGroup is in the format cn=TestGroup,dc=contoso,dc=com&nbsp;<BR>$container = 'LDAP://' + $LDAPGroup<BR>$member = 'member'<BR>$counter=0</P>
<P>$GroupEntry = New-Object DirectoryServices.DirectoryEntry($container)<BR>$GroupSearcher = New-Object DirectoryServices.DirectorySearcher($GroupEntry)<BR>$GroupSearcher.Filter="(objectClass=*)"</P>
<P>$rangeStep = 1000<BR>$rangeLow = 0<BR>$rangeHigh = $rangeLow + ($rangeStep - 1)<BR>$lastQuery = $FALSE<BR>$quitLoop = $FALSE</P>
<P>do<BR>{<BR>&nbsp;if(!$lastQuery)<BR>&nbsp;{<BR>&nbsp;&nbsp;$attribRange = 'member;range=' + $rangeLow + '-' + $rangeHigh<BR>&nbsp;}<BR>&nbsp;else<BR>&nbsp;{<BR>&nbsp;&nbsp;$attribRange = 'member;range=' + $rangeLow + '-*'<BR>&nbsp;}</P>
<P>&nbsp;# clear searcher properties and add new range<BR>&nbsp;# cast to [void] so result won't display</P>
<P>&nbsp;[void]$GroupSearcher.PropertiesToLoad.Clear()<BR>&nbsp;[void]$GroupSearcher.PropertiesToLoad.Add($attribRange)</P>
<P>&nbsp;$Results = $GroupSearcher.FindOne()</P>
<P>&nbsp;If ($Results -eq $Null)<BR>&nbsp;{<BR>&nbsp;&nbsp;write-host " "<BR>&nbsp;&nbsp;write-host "Error: Unable to find specified LDAP Group" -ForeGroundColor Red;<BR>&nbsp;&nbsp;write-host " "<BR>&nbsp;&nbsp;break<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;foreach($Res in $Results.Properties.PropertyNames)<BR>&nbsp;{<BR>&nbsp;&nbsp;# for debugging range<BR>&nbsp;&nbsp;#write-host "member range: " $Res<BR>&nbsp;}</P>
<P>&nbsp;if($Results.Properties.Contains($attribRange))<BR>&nbsp;{&nbsp;&nbsp;<BR>&nbsp;&nbsp;foreach($Res2 in $Results.Properties[$attribRange])<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;# cast each member as an ADSI object<BR>&nbsp;&nbsp;&nbsp;$adsPath = 'LDAP://' + $Res2<BR>&nbsp;&nbsp;&nbsp;$account=[ADSI]$adspath<BR>&nbsp;&nbsp;&nbsp;$account.setinfo()<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;# use PSObject to display the properties of the object</P>
<P>&nbsp;&nbsp;&nbsp;$obj = New-Object PSObject<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;$obj | Add-Member -MemberType NoteProperty -Name sAMAccountname -Value $account.properties.samaccountname[0]<BR>&nbsp;&nbsp;&nbsp;$obj | Add-Member -MemberType NoteProperty -Name DN -Value $account.path<BR>&nbsp;&nbsp;&nbsp;write $obj<BR>&nbsp;&nbsp;&nbsp;$counter = $counter + 1</P>
<P>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;if($lastQuery)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;$quitLoop = $TRUE<BR>&nbsp;&nbsp;}<BR>&nbsp;<BR>&nbsp;}<BR>&nbsp;else<BR>&nbsp;{<BR>&nbsp;&nbsp;$lastQuery = $TRUE<BR>&nbsp;}</P>
<P>&nbsp;if(!$lastQuery)<BR>&nbsp;{<BR>&nbsp;&nbsp;$rangeLow = $rangeHigh + 1<BR>&nbsp;&nbsp;$rangeHigh = $rangeLow + ($rangeStep - 1)<BR>&nbsp;}</P>
<P>}<BR>until($quitLoop) </P>
<P>write-host " "<BR>write-host "Total users:" $counter</P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
  </channel>
</rss>