Connecting to SCCM drive complications

Product: PowerShell Universal
Version: 1.4.6

I am having issues using the SCCM module with dashboards.

 $SiteCode = "MySite"
  $ProviderMachineName = "Server" # SMS Provider machine name
  $initParams = @{}
  if((Get-Module ConfigurationManager) -eq $null) {
      Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams 
  }
  if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) {
      New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams

      foreach($item in (get-psdrive)){
        new-udtypography -text "$($item.name) "
      }
  }
   Set-Location "$($SiteCode):\" @initParams

I am unable to connect to the newly created drive * Doesnt seem to create it for some reason
We have the correct log on credentials with access to SCCM.
I am also able to connect to sccm with this code on a standalone powershell window on the server with said Credentials.

Been trying to figure this out for hours, any ideas?

Does it make a difference if you change what environment it runs in? Integrated vs Windows Powershell?

I just tried switching it to 5.1 ( may have already been) and no bueno. I just get an error that no drive “MyDrive” could be found.

Just found this post and having the same issues, did you ever find a solution to your problem Cornyjam?