Point Deep

Mundeep's Tech Blog

Default Download Location for Windows 8 Software Center

Posted by mundeep on August 12, 2013

Curious about where Windows 8 Software Center (part of Microsoft System Center 2012) caches it’s downloads?
I wanted to know where the downloads where cached so i wouldn’t have to re-download them if required to re-run later down the track.

Run the following Powershell command to find out:

$Cache = gwmi -class CacheConfig -Namespace root\ccm\SoftMgmtAgent
$Cache.Location

In my case it was: C:\Windows\ccmcache which i imagine may be a default.

Thanks to David O’Briens How to configure the ConfigMgr Client cache article for helping me find this. The article also details how you can change it and some warnings if you do.

Posted in Powershell | Leave a Comment »

Clearing Timer Services

Posted by mundeep on August 13, 2012

Problem
The following error appears in (a) Event Viewer & (b) Health Analyzer as a critical item:

The SharePoint Health Analyzer detected an error. One or more services have started or stopped unexpectedly.
The following services are managed by SharePoint, but their running state does not match what SharePoint expects: SPAdminV4. This can happen if a service crashes or if an administrator starts or stops a service using a non-SharePoint interface. If SharePoint-managed services do not match their expected running state, SharePoint will be unable to correctly distribute work to the service.
SharePoint was unable to automatically repair this error.

To stop or start a service managed by SharePoint, use the SharePoint service management interface in the SharePoint Central Administration Site. If a service has crashed, restart the service manually on the affected servers by running “net start [service name]” from a command prompt. For more information about this rule, see “http://go.microsoft.com/fwlink/?LinkID=142683″.

I checked the server to ensure the SharePoint Timer Service was running (even restarted it) but that didn’t help so I tried to run the SharePoint Configuration Wizard on the box that CA could not see the Timer Service on. It gave me the following error:

08/13/2012 14:57:46 11 ERR Exception: Microsoft.SharePoint.Administration.SPUpdatedConcurrencyException: An update conflict has occurred, and you must re-try this action. The object AnalysisServicesDiagnostics was updated by DOMAIN\SP2010SetupUser, in the psconfigui (1608) process, on machine CENTRALADMINSERVERNAME. View the tracing log for more information about the conflict.
at Microsoft.SharePoint.Administration.SPConfigurationDatabase.StoreObject(SPPersistedObject obj, Boolean storeClassIfNecessary, Boolean ensure)
at Microsoft.SharePoint.Administration.SPConfigurationDatabase.Microsoft.SharePoint.Administration.ISPPersistedStoreProvider.PutObject(SPPersistedObject persistedObject, Boolean ensure)
at Microsoft.SharePoint.Administration.SPPersistedObject.BaseUpdate()
at Microsoft.SharePoint.Administration.SPDiagnosticsServiceBase.Update()
at Microsoft.SharePoint.Administration.SPDiagnosticsService.Update()
at Microsoft.SharePoint.PostSetupConfiguration.ServicesTask.InstallServiceInConfigDB(Boolean provisionTheServiceToo, String serviceRegistryKeyName)
at Microsoft.SharePoint.PostSetupConfiguration.ServicesTask.InstallServices(Boolean provisionTheServicesToo)
at Microsoft.SharePoint.PostSetupConfiguration.ServicesTask.Run()
at Microsoft.SharePoint.PostSetupConfiguration.TaskThread.ExecuteTask()

Resolution
Apparently this is caused by the timer job cache being in an inconsistent state (in my
case due to server restore from a snapshot).

Clearing the timer job cache solved the issue.

Summary of the steps to clear the timer job:

  • Stop SharePoint Timer service on all servers in the farm.
  • Browse to C:\ProgramData\Microsoft\SharePoint\Config\{GUID} where the {GUID} folder contains a bunch of XML files and NOT the files with a “.PERSITEDFILE” extension.
  • Delete all the XML files
  • Update the contents of the Cache.ini file to just say “1″ (without quotes).
  • Restart the SharePoint Timer service on each server
  • Reanalyze the isse in Health Analyzer
  • Posted in Sharepoint | Tagged: , | 2 Comments »

    Calling powershell functions with multiple parameters

    Posted by mundeep on March 1, 2012

    When calling a powershell function with multiple parameters, ensure the parameters are passed in space separated and not comma-separated as the later causes all the values to be passed in as an array to the first parameter!

    See Stackoverflow: Powershell Multiple Function Parameters for an example.

    Posted in Powershell | Tagged: | 2 Comments »

    Active Directory Users and Computers MMC Snapin for Windows 2008

    Posted by mundeep on December 28, 2011

    Having recently been required to do a fresh install of Windows 2008 R2 for a new development server i was having trouble finding where to install the Active Directory Users and Computers MMC snapin.

    Essentially you need to install the “Active Directory Domain Controller Tools” via:

    Server Manager -> Features -> Add Features

    And then: Remote Server Administration Tools -> Role Administration Tools -> Active Directory Domain Services Tools -> Active Directory Domain Controller Tools

    Of all the places on the web i actually found this answer via the Microsoft Connect forums
    http://connect.microsoft.com/WindowsServerFeedback/feedback/details/490592/

    Posted in Uncategorized | Tagged: | Leave a Comment »

    Sharepoint list view threshold and working with large lists reference

    Posted by mundeep on November 3, 2011

    A common error to come across in Sharepoint 2010 when dealing with large lists is:

    The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.

    The following blog articles have a good explanation on how the thresholds work in Sharepoint 2010.

    Microsoft also has some official guidance on managing large lists:

    Posted in Uncategorized | Leave a Comment »

    Attaching to the right process when debugging

    Posted by mundeep on August 18, 2011

    A common problem when trying to debug an ASP.NET web application (including SharePoint based solutions) is determining which w3wp.exe process to attach to. Thankfully there are a couple of commands to help out.

    If using IIS7:
    c:\Windows\System32\inetsrv\appcmd list wp

    If using IIS6:
    cscript c:\WINDOWS\system32\iisapp.vbs

    Source: http://stackoverflow.com/questions/748927/iis-application-pool-pid

    Posted in .NET | Tagged: , , , , | 2 Comments »

    Sharepoint 2010 Remote Debugging

    Posted by mundeep on August 5, 2011

    The following is a realy good article about Remote Debugging Sharepoint 2010 webparts and worth a read if you are ever having trouble getting it working:
    http://lemonharpy.wordpress.com/2011/03/17/remote-debugging-sharepoint-2010-solutions/

    Essentially the main things to ensure are:

    1. You are running Visual Sudio Remote Debugger (msvsmon.exe)
    2. You are using an account with permissions to debug.
    3. You have placed the pdb files in the approriate folder (usually in GAC)
    4. The version of code running on the remote server is exactly the same as in the Visual Studio project you have opened (If possible it is always good to perform fresh build and deployment before trying to debug.

    Posted in .NET, Sharepoint | Tagged: , , | 1 Comment »

    c# if else alternative syntax using ? : operator

    Posted by mundeep on July 15, 2011

    One of the c# operators i tend to use a lot is the ?: operator which is essentially an alternative syntax to an if else statement. Unfortunately i often forget the order of the statements so am adding this quick post as a note for myself to easily remember :)

    Essentially:

    condition ? first_expression : second_expression;

    Is equivalent to:

    if (condition) {
     first_expression;
    }
    else {
     second_expression;
    }
    

    References:

    Posted in .NET | Tagged: , , | 2 Comments »

    Powershell Script to Import Sharepoint Organization Profiles from Active Directory

    Posted by mundeep on November 8, 2010

    Here is one of my first Powershell scripts (so improvement suggestions welcome :)

    The requirement was to script the creation of SharePoint Organization Profiles from Active Directory Organizational Units, including building the hierarchy and setting the Profile Subtype appropriately. Creation of the Organizational Profiles was based on the C# code in the How to: Create User Profiles and Organization Profiles MSDN article.

    Before running this note that i had a predefined list of profile subtypes that corresponded to the level of the organizational unit in the hierarchy. The top level was Root, next level was Group, then Division, Branch & finally Section. The following is an example of the organizational structure in terms of Profile Subtypes.

    • Department (Root Level)
      • Group #1
        • Division #1
          • Branch #1
            • Section #1
        • Division #2
          • Branch #2
            • Section #2
            • Section #3
            • Section #4
          • Branch #3
            • Section #5
            • Section #6
        • Division #4
          • Branch #7
      • Group #2
        • Division #5
          • Branch #8
            • Section #9
        • Division #6
          • Branch #9
            • Section #10
            • Section #11
            • Section #12
        • Division #6
          • Branch #9
    #Create All Organisation Profiles from AD OU's
    #Load Sharepoint Snapin
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    #Declare Some Globals for Profile Management
    $context = Get-SPServiceContext -Site http://{sharepointwebappurl}/
    $psm = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context);
    $opm = New-Object Microsoft.Office.Server.UserProfiles.OrganizationProfileManager($context)
    $rootOrg = $opm.RootOrganization
    
    #Find All Children OU's Based on Parent OU's Distinguished Name (DN)
    function Find-Child-OUs
    {
    Param ([string]$sParentDN)
    	$ldapPath = "LDAP://" + $sParentDN
    	$query = new-object system.directoryservices.directorysearcher([ADSI]$ldapPath)
    	#Only Search for OUs
    	$query.filter = "(objectClass=organizationalUnit)"
    	#Only Search One Level Deep (ie. Children)
    	$query.SearchScope = "OneLevel"
    	$results = $query.findAll()
    	Write-Host $sParentDN " has " $results.Count " children"
    	return $results
    }
    
    #Create an Organization Profile under parentOrg for provided OU
    function Create-Organization {
    Param ($ou, $parentOrg, $levelTitle)
    	Write-Host "Creating:" $ou.description "under" $parentOrg.DisplayName "of type" $levelTitle
    	$subType = $psm.GetProfileSubtype($levelTitle);
    	$orgProfile = $opm.CreateOrganizationProfile($subType, $parentOrg)
    	$orgProfile.DisplayName = $ou.description
    	$orgProfile.Commit()
    	return $orgProfile
    }
    
    #Determine Subtype Based on Level
    function Get-Level-ProfileSubtype {
    Param ($level)
    	$subtypeTitle = $level
    	switch ($level) {
    		0 { $subtypeTitle = "Root"; break }
    		1 { $subtypeTitle = "Group"; break }
    		2 { $subtypeTitle = "Division"; break }
    		3 { $subtypeTitle = "Branch"; break }
    		4 { $subtypeTitle = "Section"; break }
    		default { $subtypeTitle = "Other" }
    	}
    	return $subtypeTitle
    }
    
    #Create Organization Profiles for All OU's underneath the provided OU and Organization Profile
    function Create-Child-Orgnizations
    {
    Param ([string]$currentOuDn, $parentOrg, $level)
    	#Create the Organization
    	Write-Host "Searching for Children for: " $currentOuDn
    	$children = Find-Child-OUs $currentOuDn
    	if ($children -ne $null) {
    		Write-Host -ForegroundColor red $children.Count "OU's found under:" $currentOuDn
    		Foreach($childOu in $children)
    		{
    			$ou = $childOu.GetDirectoryEntry()
    			$ouDn = $ou.distinguishedname
    			$levelTitle = Get-Level-ProfileSubtype($level)
    
    			#Create the Child Organization
    			$newOrg = Create-Organization $ou $parentOrg $levelTitle
    			Write-Host -ForegroundColor green "OU Created: " $newOrg.DisplayName " = " $newOrg.ProfileSubtype.Name
    			$nextLevel = $level + 1
    			Create-Child-Orgnizations $ouDn $newOrg $nextLevel
    		}
    	}
    }
    
    #Create All Organization Profiles Starting from Provided OU DN
    function Create-All-Organizations {
    Param ([string]$rootOuDn)
    	Create-Child-Orgnizations $rootOuDn $rootOrg 1
    }
    

    Once you have loaded all the globals and declared all the functions above the following two lines (can be done in one) will begin the profile creation.

    #Run Creation From Root Orgnization Unit, Make sure the following matches the LDAP query to the Root OU in your AD structure.
    $rootOu = "OU=Department,DC=depttest,DC=gov,DC=au"
    Create-All-Organizations $rootOu
    

    To help with testing & re-running code i also created a couple of functions to (a) List all Organizational Profiles under a parent and (b) Delete all Organization Profiles under a parent.

    #Retrieve existing Org Profiles
    function List-OrgProfiles {
    Param($parentOrg)
    	if ($parentOrg.HasChildren) {
    		foreach ($childOrg in $parentOrg.GetChildren()) {
    			Write-Host $parentOrg.DisplayName "-" $childOrg.DisplayName
    			List-OrgProfiles $childOrg
    		}
    	}
    }
    
    #Delete existing Org Profiles
    function Delete-OrgProfiles {
    Param($parentOrg)
    	# If Parent Has Children Delete them first
    	if ($parentOrg.HasChildren) {
    		foreach ($childOrg in $parentOrg.GetChildren()) {
    			#Write-Host $childOrg.DisplayName " - " $parentOrg.DisplayName
    			Delete-OrgProfiles $childOrg
    		}
    		#Once children are deleted remove the current org
    		if ($parentOrg.RecordId -ne $opm.RootOrganization.RecordId) {
    			$opm.RemoveOrganizationProfile($parentOrg.RecordId)
    			Write-Host "Removing(" $parentOrg.DisplayName ")"
    		}
    		else {
    			Write-Host "KEEP (" $parentOrg.DisplayName ")"
    		}
    	}
    	else {
    		#If not children then delete the current org
    		if ($parentOrg.RecordId -ne $opm.RootOrganization.RecordId) {
    			$opm.RemoveOrganizationProfile($parentOrg.RecordId)
    			Write-Host "RemovingChildless(" $parentOrg.DisplayName ")"
    		}
    		else {
    			Write-Host "Childless KEEP(" $parentOrg.DisplayName ")"
    		}
    	}
    }
    

    Posted in Powershell, Sharepoint | Tagged: , , , , | Leave a Comment »

    Bug in Editing Sharepoint Organization Profiles

    Posted by mundeep on October 27, 2010

    There appears to be a bug in editing Sharepoint 2010 Organization Profiles. If you try to edit the Profile SubType without editing any other field your change is not saved. The work around is to update any other field at the same time (and then don’t forget to change that field back).

    Refer to the comments on MSDN http://msdn.microsoft.com/en-us/library/ms545122.aspx for an example on how to do this in code.

    Posted in Sharepoint | Leave a Comment »

     
    Follow

    Get every new post delivered to your Inbox.