Files
Intune/intune/Externally Sourced Remediations/DeviceCompliance/Get-CustomCompliance-File/Remediate_CustomCompliance_File.ps1
2025-05-19 15:19:36 -04:00

15 lines
586 B
PowerShell

# Ensure the specific file is in place
$filePath = "C:\Company\Compliance\requiredfile.txt"
$fileContent = "This is a required compliance file."
if (-Not (Test-Path $filePath)) {
# Create the directory if it doesn't exist
$directoryPath = [System.IO.Path]::GetDirectoryName($filePath)
if (-Not (Test-Path $directoryPath)) {
New-Item -Path $directoryPath -ItemType Directory -Force | Out-Null
}
# Create the file with the required content
New-Item -Path $filePath -ItemType File -Force | Out-Null
Set-Content -Path $filePath -Value $fileContent
}