MSEndpointMgr / IntuneAppFactory

Intune App Factory automates Win32 application packaging in Intune.
https://msendpointmgr.com/intune-app-factory
MIT License
32 stars 11 forks source link

Loganalytics primary key was hashed to string which included ambersand (&) #4

Open nithilin1 opened 11 months ago

nithilin1 commented 11 months ago

My log analytics primary key was hashed correctly in the scripting, but the hashed string included &. This caused the script to fail as the & symbol is protected.

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'c:\ADOAgent_work_temp\c3b03806-9538-471e-b928-bcbd70e48fc7.ps1'" At C:\ADOAgent_work_temp\c3b03806-9538-471e-b928-bcbd70e48fc7.ps1:4 char:285

  • ... 55-4020-bf82-8fa3c12c28f4 -SharedKey rz3tpbr7Pz3AWKi5z8xkV3A&oLC2x&nN ... ~ The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string. At C:\ADOAgent_work_temp\c3b03806-9538-471e-b928-bcbd70e48fc7.ps1:4 char:291
  • ... 0-bf82-8fa3c12c28f4 -SharedKey rz3tpbr7Pz3AWKi5z8xkV3A&oLC2x&nNtF%PFa ... ~ The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string.
    • CategoryInfo : ParserError: (:) [], ParseException
    • FullyQualifiedErrorId : AmpersandNotAllowed

(Yes, this is the hashed and old version of the key.)

I was able to solve this by using my Loganalytics secondary key. I was however unable to detect where exactly to input the needed wraps for the & symbol to avoid this problem in the future.

NickolajA commented 9 months ago

Wow that's a tough one. I don't know if this works, but give this a try:

filePath: 'Scripts/New-Win32App.ps1' arguments: -TenantID $(TenantID) -ClientID $(ClientID) -ClientSecret $(SP-IntuneAppFactory-ClientSecret) -WorkspaceID $(ReportWorkspaceID) -SharedKey """$(LA-IntuneAppFactory-PrimaryKey)"""

or;

filePath: 'Scripts/New-Win32App.ps1' arguments: -TenantID $(TenantID) -ClientID $(ClientID) -ClientSecret $(SP-IntuneAppFactory-ClientSecret) -WorkspaceID $(ReportWorkspaceID) -SharedKey "$(LA-IntuneAppFactory-PrimaryKey)"

This is a wild guess, it's probably not going to work.