Dec 01 2023 07:11 AM - edited Dec 01 2023 07:12 AM
i have tested my script to run locally and it does work. When I intune wrap and deploy the package it does not work. Can anyone tell me why when its goes thru intune it's spit an error saying it couldnt detect after it was installed but it never installs.
$sourceFolderPath = "C:\Users\Randolph\OneDrive - RedCup, Inc\Intune Packages\Chart Templates 11_30_23" # Specify the path to the source folder containing the new files
$specificSubfolder = "Charts" # Copy files from the specific subfolder in the source folder to the destination folder
$destinationFolderPath = "$env:APPDATA\Microsoft\Templates\Charts" # Specify the path to the destination folder
$specificSubfolderPath = Join-Path -Path $sourceFolderPath -ChildPath $specificSubfolder
# Remove the destination folder if it exists, excluding specific folders
if (Test-Path -Path $destinationFolderPath) {
$excludedFolders = @(".dotm", "Document Themes", "SmartArt Graphics", "LiveContent")
$itemsToExclude = Get-ChildItem -Path $destinationFolderPath -Directory | Where-Object { $excludedFolders -contains $_.Name }
$itemsToDelete = Get-ChildItem -Path $destinationFolderPath -File | Where-Object { $excludedFolders -contains $_.Name.Split(".")[0] }
$itemsToDelete | Remove-Item -Force
$itemsToExclude | ForEach-Object { Remove-Item -Path $_.FullName -Recurse -Force }
}
# Create the destination folder
New-Item -ItemType Directory -Path $destinationFolderPath | Out-Null
# Copy files from the specific subfolder in the source folder to the destination folder using robocopy with /MIR switch
Robocopy $specificSubfolderPath $destinationFolderPath /MIR
Dec 01 2023 02:24 PM
Hello @Keke_000
Welcome to the Microsoft community, my name is Recep I'll be happy to help you today.
# Set Execution Policy to Bypass
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
This ensures that the script can run even if there are restrictions in place.
$logFilePath = "$env:TEMP\ScriptLog.txt"
Start-Transcript -Path $logFilePath -Append
# Your existing script code here
Stop-Transcript
After the deployment, check the log file for any errors or unexpected behavior.
For example, create a separate PowerShell script for detection, and then configure Intune to use it. The detection script might check for the existence of a file or registry key that indicates a successful deployment.
# Detection script example
$filePath = "$env:APPDATA\Microsoft\Templates\Charts\SomeFile.txt"
if (Test-Path -Path $filePath) {
Write-Output "Success"
} else {
Write-Output "Failure"
}
Configure this script as the detection method in your Intune deployment.
If I have answered your question, please mark your post as Solved If you like my response, please give it a Like Appreciate your Kudos! Proud to contribute! :) |
Dec 02 2023 12:24 AM