Jump to content


Always

Established Members
  • Posts

    22
  • Joined

  • Last visited

Posts posted by Always

  1. I want to build and capture a ref image.

    Have a "Microsoft .NET Framework 4.7.2" Application

    Have checked "Allow this application to be installed from install application task sequence action without being deployed"

    Deployment type:

    Install: "NDP472-KB4054530-x86-x64-AllOS-ENU.exe" /norestart /q /log "%windir%\Logs\Microsoft_.Net_Framework_4.7.2_Install.log"

    Uninstall: msiexec.exe /x {09CCBE8E-B964-30EF-AE84-6537AB4197F9} /q /l*v "%windir%\Logs\Microsoft_.Net_Framework_4.7.2_Uninstall.log"

    Detecion: {09CCBE8E-B964-30EF-AE84-6537AB4197F9}

    Above Applications work on a live running device.

    But it fail under a task sequence.

    My question is why and how do i debug on this?

    ZMvEjj6.png

     

  2. Hi WN

    I created a function to connect to the CMSite and load the cmdlet for ConfigurationManager.

    Could the function be improved in any way or is it as good it can be? is the logic best practice or?

    You can download it at : https://gallery.technet.microsoft.com/Connect-ConfigMgr64-db5e9d0a

    function Connect-ConfigMgr64
    {
    	$initParams = @{ }
    	if ((Get-Module ConfigurationManager) -eq $null)
    	{
    		try
    		{
    			Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams -Scope Global
    		}
    		catch
    		{
    			$ModulePath = (Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\ConfigMgr10\Setup -Name "UI Installation Directory").'UI Installation Directory'
    			Import-Module $ModulePath\bin\ConfigurationManager.psd1 -Scope Global
    		}
    	}
    	if ((Get-Module ConfigurationManager) -ne $null)
    	{
    		$SiteCode = Get-PSDrive -PSProvider CMSITE
    		if ((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null)
    		{
    			$ProviderMachineName = (Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\ConfigMgr10\AdminUI\Connection -Name Server).Server
    			New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams
    		}
    		if ((Get-PSProvider -PSProvider CMSite) -ne $null)
    		{
    			Set-Location $SiteCode":\"
    			Write-Host 'Type "Get-Command -Module ConfigurationManager" for a list of SCCM CMDlets.' -ForegroundColor Green
    		}
    		else
    		{
    			$CustomError = [String]"Error: Can't find CMSite provider"
    			Throw $CustomError
    		}
    	}
    	else
    	{
    		$CustomError = [String]"Unable to locate System Center Configuration Manager installation folder!"
    		Throw $CustomError
    	}
    }
    
    Connect-ConfigMgr64

     

  3. 9 hours ago, Peter33 said:

    The Get-CMGlobalCondition CMDlet does not return a valid object for the AddRequirement property. This is a known problem and will be addressed in future CB versions.

     

    There is a workaround available though.

    https://social.technet.microsoft.com/Forums/ie/en-US/95e6ad51-0b5c-4d65-9831-753db4e3b557/how-to-add-an-existing-global-condition-to-an-application-deployment-type-via-powershell?forum=configmanagerapps

    Thanks for the link

    Got it to work with following code

    Function Connect-SCCM
    {
    	Param (
    		[Parameter(Mandatory = $True)]
    		[String]$SiteCode,
    		[Parameter(Mandatory = $True)]
    		[String]$Primary
    	)
    	If (!(Get-Module -name ConfigurationManager))
    	{
    		import-module $env:SMS_ADMIN_UI_PATH.Replace('bin\i386', 'bin\ConfigurationManager.psd1') -force
    		if ((get-psdrive $SiteCode -erroraction SilentlyContinue | Measure-Object).Count -ne 1)
    		{
    			new-psdrive -Name $SiteCode -PSProvider 'AdminUI.PS.Provider\CMSite' -Root $Primary -Scope Global
    		}
    		
    		$ConsoleFolder = $Env:SMS_ADMIN_UI_PATH -replace '\\i386', ''
    		[System.Reflection.Assembly]::LoadFrom("$($ConsoleFolder)\Microsoft.ConfigurationManagement.ApplicationManagement.dll") | Out-Null
    	}
    } #end function Connect-SCCM
    
    
    Function Get-SCCMGlobalCondition($name, $siteServerName)
    {
    	$connectionManager = new-object Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlConnectionManager
    	$isConnected = $connectionManager.Connect($siteServerName)
    	$SCCMserver = $connectionManager.NamedValueDictionary.ServerName
    	$SCCMsitecode = "PRI"
    	$SCCMNamespace = "root\sms\site_PRI"
    	#$nameformated = $name.Replace(" ","")
    	$objResult = Get-WmiObject -ComputerName $siteServerName -Class SMS_GlobalCondition -Namespace $SCCMNamespace -filter "ModelName like '%$name%' "
    	if ($objResult -eq $null)
    	{
    		$objResult = Get-WmiObject -ComputerName $siteServerName -Class SMS_GlobalCondition -Namespace $SCCMNamespace -filter "ModelName = '$name'"
    	}
    	if ($objResult -eq $null)
    	{
    		$objResult = Get-WmiObject -ComputerName $siteServerName -Class SMS_GlobalCondition -Namespace $SCCMNamespace -filter "LocalizedDisplayName = '$name'"
    	}
    	$objResult | Where-Object{$_.PlatformType -eq 1}
    	
    	
    }
    
      <#
     
            .SYNOPSIS
                Creates a Global Condition rule of type [Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Rules.Rule]. 
                This rule can be added as a requirement for an deployment type
    
            .DESCRIPTION
                This function will Create a rule for an global condition
                 
            .PARAMETER SiteServerName
               Name of the SCCM Site server to check Global Conditions
      
            .PARAMETER GlobalCondition
                Name of the global condition you wanted to use
     
            .PARAMETER Operator
                Operator used to validate the rule. Accepted values are Equals,NotEquals,GreaterThan,LessThan,Between,GreaterEquals,LessEquals,BeginsWith,NotBeginsWith,EndsWith,NotEndsWith,Contains,NotContains,AllOf,OneOf,NoneOf,SetEquals,Existential (Custom),NotExistential (Custom)
                
            .PARAMETER Value
                Value on which the rule should check. Use MB when data value is needed
    
            .PARAMETER SettingSourceType
               Default value is CIM if type is of other value please type this value. Possible values:
      Registry, IisMetabase, SqlQuery, WqlQuery, Script, XPathQuery, ADQuery, Complex, SoftwareUpdate, File, 
      Folder, RegistryKey, Assembly, Uri, Expression, CIM, ParameterizedSetting, PlistKey, MSI, MacDetection
      
     
            .EXAMPLE
                Create-SCCMGlobalConditionsRule . "TotalPhysicalMemory" "GreaterEquals" 524288000 "CIM"
                 
                Creates a rule where Total Phyiscal memory is greater than or equals to 500 MB
     
            .EXAMPLE
                
                Create-SCCMGlobalConditionsRule . "CPU" "GreaterThan" 10000 "CIM"
                
                Creates a rule where the cpu speed is greater than 1 GHZ
     
     #>
    Function Create-SCCMGlobalConditionsRule($siteServerName, $GlobalCondition, $Operator, $Value, $SettingSourceType)
    {
    	if ($GlobalCondition.ModelName -eq $null)
    	{
    		$GlobalCondition = Get-SCCMGlobalCondition $GlobalCondition $siteServerName
    	}
    	
    	if ($GlobalCondition -eq $null)
    	{
    		Write-Error "Global condition not found"
    		return
    	}
    	
    	$gcTmp = $GlobalCondition.ModelName.Split("/")
    	$gcScope = $gcTmp[0]
    	$gcLogicalName = $gcTmp[1]
    	$gcDataType = $GlobalCondition.DataType
    	$gcExpressionDataType = [Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.DataType]::GetDataTypeFromTypeName($gcDataType)
    	
    	if ($operator.ToLower() -eq "notexistential" -OR $operator.ToLower() -eq "existential")
    	{
    		$gcExpressionDataType = [Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.DataType]::Int64
    	}
    	#Retrieving logical name of setting 
    	$settingsxml = [xml] ([wmi]$GlobalCondition.__PATH).SDMPackageXML
    	if ($settingsxml.DesiredConfigurationDigest.GlobalSettings.AuthoringScopeId -eq "GLOBAL")
    	{
    		$global = $true
    		$SettingLogicalName = "$($gcLogicalName)_Setting_LogicalName"
    	}
    	else
    	{
    		$SettingLogicalName = $settingsxml.DesiredConfigurationDigest.GlobalSettings.Settings.FirstChild.FirstChild.LogicalName
    	}
    	if (!($SettingLogicalName))
    	{
    		$SettingLogicalName = $settingsxml.DesiredConfigurationDigest.GlobalExpression.LogicalName
    	}
    	
    	#Checking for ConfigurationItemSetting 
    	
    	if ($SettingSourceType -ne $null -AND $SettingSourceType -ne "")
    	{
    		$CISettingSourceType = [Microsoft.ConfigurationManagement.DesiredConfigurationManagement.ConfigurationItemSettingSourceType]::$SettingSourceType
    	}
    	else
    	{
    		$CISettingSourceType = [Microsoft.ConfigurationManagement.DesiredConfigurationManagement.ConfigurationItemSettingSourceType]::CIM
    	}
    	
    	#if ($global){
    	$arg = @($gcScope,
    		$gcLogicalName
    		$gcExpressionDataType,
    		$SettingLogicalName,
    		$CISettingSourceType
    	)
    	$reqSetting = new-object  Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.GlobalSettingReference -ArgumentList $arg
    	
    	
    	#custom properties Existential
    	if ($operator.ToLower() -eq "notexistential")
    	{
    		$operator = "Equals"
    		$Value = 0
    		$reqSetting.MethodType = "Count"
    	}
    	if ($operator.ToLower() -eq "existential")
    	{
    		$operator = "NotEquals"
    		$Value = 0
    		$reqSetting.MethodType = "Count"
    		
    		
    	}
    	
    	$arg = @($value,
    		$gcExpressionDataType
    	)
    	$reqValue = new-object Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.ConstantValue -ArgumentList $arg
    	
    	$operands = new-object "Microsoft.ConfigurationManagement.DesiredConfigurationManagement.CustomCollection``1[[Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.ExpressionBase]]"
    	$operands.Add($reqSetting) | Out-Null
    	$operands.Add($reqValue) | Out-Null
    	
    	#Changing Equals to IsEquals 
    	if ($operator.ToLower() -eq "equals") { $operator = "IsEquals" }
    	$Expoperator = Invoke-Expression [Microsoft.ConfigurationManagement.DesiredConfigurationManagement.ExpressionOperators.ExpressionOperator]::$operator
    	
    	
    	
    	
    	if ($GlobalCondition.DataType -eq "OperatingSystem")
    	{
    		
    		$operands = new-object "Microsoft.ConfigurationManagement.DesiredConfigurationManagement.CustomCollection``1[[Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.RuleExpression]]"
    		foreach ($os in $value)
    		{
    			$operands.Add($os)
    		}
    		$arg = @($Expoperator,
    			$operands
    		)
    		$expression = new-object Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.OperatingSystemExpression -ArgumentList $arg
    		
    	}
    	else
    	{
    		$arg = @($Expoperator,
    			$operands
    		)
    		$expression = new-object Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Expressions.Expression -ArgumentList $arg
    		
    	}
    	
    	
    	$anno = new-object Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Rules.Annotation
    	$annodisplay = "$($GlobalCondition.LocalizedDisplayName) $operator $value"
    	$arg = @(
    		"DisplayName",
    		$annodisplay,
    		$null
    	)
    	$anno.DisplayName = new-object Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Rules.LocalizableString -ArgumentList $arg
    	
    	$arg = @(
    		("Rule_" + [Guid]::NewGuid().ToString()),
    		[Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Rules.NoncomplianceSeverity]::None,
    		$anno,
    		$expression
    	)
    	$rule = new-object "Microsoft.SystemsManagementServer.DesiredConfigurationManagement.Rules.Rule" -ArgumentList $arg
    	
    	
    	return $rule
    }
    
    $Primary = 'CM01.lab.local'
    $SiteCode = "PRI"
    
    Connect-SCCM -SiteCode $SiteCode -Primary $Primary
    
    $applicationname = 'Igor Pavlov 7-Zip 18.05 (x64 edition) 18.05.00.0 V1'
    $GC = "Is user is logged on"
    $DTName = '_Interactive'
    
    set-location "$($SiteCode):"
    
    $rule = Create-SCCMGlobalConditionsRule -GlobalCondition $gc -Operator "IsEquals" -Value "True" -siteServerName $Primary -SettingSourceType 'WqlQuery'
    
    Set-CMDeploymentType -ApplicationName $applicationname -DeploymentTypeName $DTName -AddRequirement $rule -verbose

     

  4. Hi WN

    I trying to add a custom Global Condition to a deployment type. But cant figure out how it done. and a big error so ??

    if (!(Get-CMGlobalCondition -Name "Is user is logged on"))
    {
        Remove-Item "$env:temp\Is_user_is_logged_on.ps1" -ea SilentlyContinue
        Add-Content -Encoding UTF8 "$env:temp\Is_user_is_logged_on.ps1" "[bool] (Get-Process explorer –ea 0)"
        New-CMGlobalCondition -Name "Is user is logged on" -Description "Check if an user is logged on" -DeviceType Windows -DataType Boolean -ScriptLanguage PowerShell -FilePath "$env:temp\Is_user_is_logged_on.ps1"
        Remove-Item "$env:temp\Is_user_is_logged_on.ps1" -ea SilentlyContinue
    }

    $ApplicationName = "Igor Pavlov 7-Zip 18.05 (x64 edition) 18.05.00.0 V1"
    $condition = Get-CMGlobalCondition -Name "Is user is logged on"
    Set-CMDeploymentType -ApplicationName "$ApplicationName" -DeploymentTypeName "_Silent" -AddRequirement "$condition.Rule"

    console return:

    Cannot convert value "[SecurityVerbs(-1)]
    instance of SMS_GlobalCondition

    ......

    ref: https://configurationmanager.uservoice.com/forums/300492-ideas/suggestions/32636506-powershell-cmdlet-for-adding-global-conditions-as

    anyone done this before?

  5. I do as i unsually do download the sccm driverpack from lenovo inject it into a driver package in sccm. Create a wmi query to target the right maschine in the TS.

    But get an error on the driver apply how to fix this issue=?

  6. Hi here,

    Im pretty new at OSD deployment but working on it to master this beast :D

    Currently having differenculties with a Build and Capture.

    Running 1610.

    What i know.

    The Build and Capture works with one application - Framework 1.1

    Then I added just after a new application - Framework 4.6.2

    Looking in smsts.log i have these errors

    • NotifyProgress received: 16 (Application failed to evalute )
      Have testet the application on a already running mashine. Deployed from sccm and it evalute fine in software center Status Installed.
       
    • NotifyProgress received: 4 (Application failed to install )
      The content is locally on the mashine.
      C:\windows\ccmcache\2
      Have run the script install manual and it works fine there.
       
    • Microsoft .Net Framework 4.6.2
      Content: Download content from dp and run locally
      Detection: SOFTWARE\Classes\Installer\Products\B4C5FD36FB3E64330A335CB7224FC4E9\ProductName -equals Microsoft .NET Framework 4.6.2

    The build os is Windows 7 SP1 RAW untouched.

    Anyone know where i shoud start looking?

  7. Hi WN

     

    im working on a script where i want to pass a param to the script.

     

    When I run it without any param it install the regedit changes.

     

    I want to use the same script for the clean up.

     

    like this:

     

    newdev.ps1 -uninstall

     

    then do this and this how do i get this to work?

  8. I running a small SCCM2012R2 Lab in vmware workstation 11



    I could fine capture Windows 7 32bit and 64bit



    But when i try to capture Windows XP Pro SP3 i get following error:



    post-27179-0-34026800-1435164218.png



    What to do from here?? My Mission is to simulate a XP to Windows 7 Migration but first I need to be able to Capture Windows XP so i can deploy XP machines



    Hope someone here could help me further with my lab test


  9. I running a small SCCM2012R2 Lab in vmware workstation 11

     

    I could fine capture Windows 7 32bit and 64bit

     

    But when i try to capture Windows XP Pro SP3 i get following error:

     

    post-27179-0-34026800-1435164218_thumb.png

     

    What to do from here?? My Mission is to simulate a XP to Windows 7 Migration but first I need to be able to Capture Windows XP so i can deploy XP machines

    Hope someone here could help me further with my lab test

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.