New-UDDashboard -Title 'PowerShell Universal' -Content{
Import-Module ActiveDirectory
# Site configuration
$SiteCode = "MySite"
$ProviderMachineName = "Server"
# Customizations
$initParams = @{}
# Import the ConfigurationManager.psd1 module
if($null -eq (Get-Module ConfigurationManager)) {
Import-Module "C:\Program Files (x86)\Microsoft Endpoint Manager\AdminConsole\bin\ConfigurationManager\ConfigurationManager.psd1" @initParams
}
# Connect to the site's drive if it is not already present
if($null -eq (Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue)) {
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams
}
# Set the current location to be the site code.
Set-Location "$($SiteCode):\" @initParams
I’ve found a couple forum posts regarding SCCM integration but have found none with any solutions being posted; has anyone found a way to integrate SCCM into Universal Dashboard, and if so, could you provide an example?
I cannot get the location to set no matter where I place the code in the dashboard’s script, whether before New-UDDashboard or nested within the contents. I’ve tried running the script in the default environment, Windows PowerShell, and 5.1.19041.1023.
Here’s the log output on the dashboard, it doesn’t change in either scenario:
Waiting for dashboard information…
Dashboard information received. Starting dashboard.
Creating services.
C:\Program Files (x86)\Universal\Modules\Universal\Universal.psd1
Starting scheduler.
Dashboard configuration complete.
I have not tried it in an environment startup script. As near as I can tell it doesn’t even run the lines of code in the script. I attempted to use wait-debugger, but the dashboard does not show in the debugging section even though the page appears to be waiting.
If I do a get-module in the console I can see that the module is imported, but it doesn’t appear to like to set the location, nor does it recognize any of the module’s commands.
So the toast shows our site, however when attempting to run a command from the module we get this error:
This command cannot be run from the current drive. To run this command you must first connect to a Configuration Manager drive.
An error occurred: This command cannot be run from the current drive. To run this command you must first connect to a Configuration Manager drive.
Endpoint: bd2d171f-11f8-4900-9f61-d844573b6d2b
Session: , User:
Which indicates that the location isn’t set properly.
# Site configuration
$SiteCode = "MySite" # Site code
$ProviderMachineName = "MyServer" # SMS Provider machine name
# Customizations
$initParams = @{}
#$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging
#$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors
# Do not change anything below this line
# Import the ConfigurationManager.psd1 module
if($null -eq (Get-Module ConfigurationManager)) {
Import-Module "C:\Program Files (x86)\Microsoft Endpoint Manager\AdminConsole\bin\ConfigurationManager\ConfigurationManager.psd1" @initParams
}
# Connect to the site's drive if it is not already present
if($null -eq (Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue)) {
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams
}
# Set the current location to be the site code.
Set-Location "$($SiteCode):\" @initParams
Dashboard loads fine, but the location is not set. (Get-Location).Path returns C:\ProgramData\UniversalAutomation\Repository.
I have a page that I’ve built to allow people to add MAC address exceptions using the ConfigMgr module. I have a script that I wrote to do the actual work and call it from the dashboard via Invoke-PSUScript.
It seems like you’re working on integrating SCCM into Universal Dashboard, and you’re facing some challenges with setting the SCCM drive location. This can indeed be a bit tricky.For more specific guidance on integrating SCCM into your Universal Dashboard, you might find valuable insights and examples on https://learnmesccm.com. They often provide detailed resources related to SCCM that could help you overcome this issue. Additionally, when dealing with script placement and environment configurations, it’s essential to ensure that everything is set up correctly. Don’t hesitate to seek assistance on relevant forums or communities if you continue to face difficulties.