CCMEXEC.COM – System Center blog

CCMEXEC.COM – by Jörgen Nilsson

Browsing Posts tagged Powershell

I wrote a handy little VBscript a couple of years ago that can be triggered by a Status Filter Rule to automatically distribute packages as soon as they are created to a Distribution Point. When upgrading to MDT 20213 Update 1 I missed this so I re-wrote it in Powershell. The script is triggered by a Status Filter Rule and then distributes the content to the DP group that is configured in the Powershell script. I am lazy I know ;-)

Below is the script, change the $DPgroup variable to the name of your DP group.
It can also be configured with the $CopyToShare variable to configure the package to be available on the package share if that is used. I used it in some environments to speed up OS deployment and use the “Access content directly” option for the Task Sequence when bandwidth is no issue. Save the script in a folder on the Primary Site server.

Param(

[string]$PackageID

)

$DPgroup = "All DP"

$CopyToShare = $False

import-module $env:SMS_ADMIN_UI_PATH.Replace("bin\i386","bin\ConfigurationManager.psd1") -force

[String]$SiteCode = $(Get-WMIObject -ComputerName “$ENV:COMPUTERNAME” -Namespace “root\SMS” -Class “SMS_ProviderLocation”).SiteCode

new-psdrive -Name $SiteCode -PSProvider “AdminUI.PS.Provider\CMSite” -Root “$ENV:COMPUTERNAME” -Description “SCCM Primary Site”

Set-Location “$SiteCode`:”

# Configure the package to be availble on DP Share

if($CopyToShare) {

Set-CMPackage -Id $PackageID -CopyToPackageShareOnDistributionPoints $True -ErrorAction SilentlyContinue

}

# Add to distributionpoint group

Start-CMContentDistribution –PackageID $PackageID –DistributionPointGroupName $DPgroup

Param(

[string]$PackageID
)
import-module $env:SMS_ADMIN_UI_PATH.Replace("bin\i386","bin\ConfigurationManager.psd1") -force
[String]$SiteCode = $(Get-WMIObject -ComputerName “$ENV:COMPUTERNAME” -Namespace “root\SMS” -Class “SMS_ProviderLocation”).SiteCode
[String]$DPgroup = "All DP"
new-psdrive -Name $SiteCode -PSProvider “AdminUI.PS.Provider\CMSite” -Root “$ENV:COMPUTERNAME” -Description “SCCM Primary Site”
Set-Location “$SiteCode`:”
# add to distributionpoint group
Start-CMContentDistribution –PackageID $PackageID –DistributionPointGroupName $DPgroup



The Status filter rule we need to create will look like this, trigger on Message ID: 30000

StatusFilterRule

For the Actions to run, the following command line needs to be used like shown below.

C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -NoProfile -ExecutionPolicy ByPass -File E:\Scripts\Addtodp.ps1 “%msgis02″

The variable %msgis02% will be used to pass the package ID to the script from the Status Message.

StatusFilterRule2Then you are all done, no more forgetting to add a package to a DP anymore.

Microsoft Edge is the new always up-to-date, ultrafast and modern browser in Windows 10 CBB It is not included in the Long-Term Servicing Build of Windows 10. Microsoft Edge doesn’t share favorites with IE, it has its own favorites store which is located here: %Userprofile%\appdata\local\packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\ac\MicrosoftEdge\User\Default\favorites

In Edge there is a built-in feature to copy favorites from IE, Chrome or Firefox. However if you are using folder redirection for IE favorites so they aren’t located under %userProfile%\Favorites anymore then you will be met with this error message when you try to copy the favorites from IE in the Edge browser.

Edgeimport1

I created a little PowerShell script that will copy the favorites from both a redirected and a non-redirect favorites folder that can be run in the user context to copy the favorites from IE to Edge. It also deletes the registry key necessary for Edge to read the new favorites, it also excludes $recycle.bin file that can exist in the redirected favorites folder.

I have uploaded the script to Technet Galleries, it can be found here: https://gallery.technet.microsoft.com/Powerhsell-script-to-copy-1e300de5

Note that Edge must have been started once so that all the registry keys are inplace. I am hoping that the Edge team will solve this for us in the future but until then launching and stopping the Edge browser when you build your reference image in MDT and then use Copyprofile during deployment solves the need to start Edge once before copying of the favorites are successful.
Thanks to my colleagues Johan and Petrus for assisting in the testing and verification.

I hope this can be useful.