From e326cd97c0c0f58f3c9a67bea7941f4cfed10a1b Mon Sep 17 00:00:00 2001 From: DistractADD <59945168+DistractADD@users.noreply.github.com> Date: Fri, 2 Feb 2024 08:54:43 +1000 Subject: [PATCH] Added from Evernote export --- Powershell/From Evernote/Connect_To_365.ps1 | 4 + .../From Evernote/Disconnect_From_365.ps1 | 1 + .../ESD2WIM-WIM2ESD.cmd | 487 +++++++++++++++ Powershell/From Evernote/Intune.ps1 | 267 ++++++++ .../Intune-run-first.bat | 28 + .../Bitlocker.zip | Bin 0 -> 13261 bytes .../Robocopy with file exclude.html | 588 ++++++++++++++++++ ...ation asking to manage device win10-11.ps1 | 11 + .../Install-Teamviewer.ps1 | 54 ++ .../TeamviewerInstall.ps1 | 51 ++ .../From Evernote/Uninstall-IntuneClient.ps1 | 40 ++ 11 files changed, 1531 insertions(+) create mode 100644 Powershell/From Evernote/Connect_To_365.ps1 create mode 100644 Powershell/From Evernote/Disconnect_From_365.ps1 create mode 100644 Powershell/From Evernote/Export install.esd to install.wim files/ESD2WIM-WIM2ESD.cmd create mode 100644 Powershell/From Evernote/Intune.ps1 create mode 100644 Powershell/From Evernote/PSC InTune Readiness Script Call Batch files/Intune-run-first.bat create mode 100644 Powershell/From Evernote/Remote Enable BitLocker files/Bitlocker.zip create mode 100644 Powershell/From Evernote/Robocopy with file exclude.html create mode 100644 Powershell/From Evernote/Stop organisation asking to manage device win10-11.ps1 create mode 100644 Powershell/From Evernote/Teamviewer Install files/Install-Teamviewer.ps1 create mode 100644 Powershell/From Evernote/Teamviewer Install files/TeamviewerInstall.ps1 create mode 100644 Powershell/From Evernote/Uninstall-IntuneClient.ps1 diff --git a/Powershell/From Evernote/Connect_To_365.ps1 b/Powershell/From Evernote/Connect_To_365.ps1 new file mode 100644 index 0000000..f4f24e5 --- /dev/null +++ b/Powershell/From Evernote/Connect_To_365.ps1 @@ -0,0 +1,4 @@ +Set-ExecutionPolicy RemoteSigned +$UserCredential = Get-Credential +$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection +Import-PSSession $Session \ No newline at end of file diff --git a/Powershell/From Evernote/Disconnect_From_365.ps1 b/Powershell/From Evernote/Disconnect_From_365.ps1 new file mode 100644 index 0000000..11c7d92 --- /dev/null +++ b/Powershell/From Evernote/Disconnect_From_365.ps1 @@ -0,0 +1 @@ +Remove-PSSession $Session \ No newline at end of file diff --git a/Powershell/From Evernote/Export install.esd to install.wim files/ESD2WIM-WIM2ESD.cmd b/Powershell/From Evernote/Export install.esd to install.wim files/ESD2WIM-WIM2ESD.cmd new file mode 100644 index 0000000..5aeebef --- /dev/null +++ b/Powershell/From Evernote/Export install.esd to install.wim files/ESD2WIM-WIM2ESD.cmd @@ -0,0 +1,487 @@ +@echo off +cls +echo. +ECHO =============================================================================== +echo Paste or write the complete path to install.esd or install.wim file +echo ^(without quotes marks "" even if the path contains spaces^) +ECHO =============================================================================== +echo. +set /p WIMFILE= +if "%WIMFILE%"=="" echo Incorrect file name or path&echo.&PAUSE&GOTO :QUIT + +title ESD ^<^> WIM +color 1f +%windir%\system32\reg.exe query "HKU\S-1-5-19" >nul 2>&1 || ( +echo ------- +echo *** WARNING *** +echo ------- +echo. +echo. +echo ADMINISTRATOR PRIVILEGES NOT DETECTED +echo ____________________________________________________________________________ +echo. +echo This script require administrator privileges. +echo. +echo To do so, right click on this script and select 'Run as administrator' +echo. +echo. +echo. +echo Press any key to exit... +pause >nul +goto :eof +) +cd /d "%~dp0" +if exist "%CD%\dism\dism.exe" set Path=%CD%\dism;%Path% +SET ERRORTEMP= +set /A count=0 + +dism /get-wiminfo /wimfile:"%WIMFILE%" >nul 2>&1 || ( +echo. +echo Incorrect file name or path +echo. +echo Press any key to exit. +pause >nul +goto :eof +) +setlocal EnableDelayedExpansion +FOR /F "tokens=2 delims=: " %%i IN ('dism /english /Get-WimInfo /WimFile:"%WIMFILE%" ^| findstr "Index"') DO SET images=%%i +for /L %%i in (1, 1, %images%) do call :setcount %%i + +if "%WIMFILE:~-3%"=="esd" GOTO :ESDMENU +if "%WIMFILE:~-3%"=="wim" GOTO :WIMMENU +exit + +:setcount +set /A count+=1 +for /f "tokens=1* delims=: " %%i in ('dism /english /get-wiminfo /wimfile:"%WIMFILE%" /index:%1 ^| find /i "Name"') do set name%count%="%%j" +goto :eof + +:ESDMENU +cls +ECHO =============================================================================== +ECHO. Detected ESD file contains %images% indexes: +ECHO. +for /L %%i in (1, 1, %images%) do ( +ECHO. %%i. !name%%i! +) +ECHO. +ECHO =============================================================================== +ECHO. Options: +ECHO =============================================================================== +ECHO. 1 - Export 1st index +ECHO. 2 - Export all indexes +ECHO. 3 - Export selected single index +ECHO. 4 - Export selected range of indexes +ECHO =============================================================================== +ECHO. Press 'Q' to Quit +ECHO =============================================================================== + +choice /c 1234q /n /m "Choose a menu option, or Q to quit: " +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP%==1 GOTO :ESD1 +IF %ERRORTEMP%==2 GOTO :ESD2 +IF %ERRORTEMP%==3 GOTO :ESD3 +IF %ERRORTEMP%==4 GOTO :ESD4 +IF %ERRORTEMP%==5 GOTO :QUIT +GOTO :MAINMENU + +:ESD1 +cls +IF EXIST "%CD%\install.wim" ( +ECHO =============================================================================== +ECHO. An install.wim file is already present in the current folder. +ECHO =============================================================================== +ECHO. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) +ECHO =============================================================================== +Echo Exporting ESD Index 1 to a new install.wim file... +ECHO =============================================================================== +mkdir temp +dism /Quiet /Capture-Image /ImageFile:install.wim /CaptureDir:.\temp /Name:container /Compress:max /CheckIntegrity +rmdir /s /q temp +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:1 /DestinationImageFile:install.wim /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +dism /Quiet /Delete-Image /ImageFile:install.wim /Index:1 /CheckIntegrity +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT + +:ESD2 +cls +IF EXIST "%CD%\install.wim" ( +ECHO =============================================================================== +ECHO. An install.wim file is already present in the current folder. +ECHO =============================================================================== +ECHO. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) +ECHO =============================================================================== +Echo Exporting ESD Index 1 to a new install.wim file... +ECHO =============================================================================== +mkdir temp +dism /Quiet /Capture-Image /ImageFile:install.wim /CaptureDir:.\temp /Name:container /Compress:max /CheckIntegrity +rmdir /s /q temp +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:1 /DestinationImageFile:install.wim /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +dism /Quiet /Delete-Image /ImageFile:install.wim /Index:1 /CheckIntegrity + +if "%images%"=="1" ( +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) + +for /L %%i in (2, 1, %images%) do ( +ECHO. +ECHO =============================================================================== +Echo Exporting ESD Index %%i to install.wim file... +ECHO =============================================================================== +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:%%i /DestinationImageFile:install.wim /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +) +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT + +:ESD3 +cls +set _index= +ECHO =============================================================================== +ECHO. Detected ESD file contains %images% indexes: +ECHO. +for /L %%i in (1, 1, %images%) do ( +ECHO. %%i. !name%%i! +) +ECHO. +ECHO =============================================================================== +ECHO. Enter desired index number to export +ECHO =============================================================================== +ECHO. Enter zero '0' to go back to Main Menu +ECHO =============================================================================== +set /p _index= ^> +if /i "%_index%"=="0" goto :ESDMENU +if [%_index%]==[] goto :ESD3 +if /i %_index% GTR %images% echo.&echo Selected number is higher than available indexes&echo.&PAUSE&goto :ESD3 + +cls +IF EXIST "%CD%\install.wim" ( +ECHO =============================================================================== +ECHO. An install.wim file is already present in the current folder. +ECHO =============================================================================== +ECHO. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) +ECHO =============================================================================== +Echo Exporting ESD Index %_index% to a new install.wim file... +ECHO =============================================================================== +mkdir temp +dism /Quiet /Capture-Image /ImageFile:install.wim /CaptureDir:.\temp /Name:container /Compress:max /CheckIntegrity +rmdir /s /q temp +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:%_index% /DestinationImageFile:install.wim /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +dism /Quiet /Delete-Image /ImageFile:install.wim /Index:1 /CheckIntegrity +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT + +:ESD4 +cls +set _range= +set _start= +set _end= +ECHO =============================================================================== +ECHO. Detected ESD file contains %images% indexes: +ECHO. +for /L %%i in (1, 1, %images%) do ( +ECHO. %%i. !name%%i! +) +ECHO. +ECHO =============================================================================== +ECHO. Enter desired Range of indexes to export: Start-End +ECHO. Example: 2-4 or 1-3 or 3-4 +ECHO =============================================================================== +ECHO. Enter zero '0' to go back to Main Menu +ECHO =============================================================================== +set /p _range= ^> +if /i "%_range%"=="0" goto :ESDMENU +if [%_range%]==[] goto :ESD4 +for /f "tokens=1 delims=-" %%i in ('echo %_range%') do set _start=%%i +for /f "tokens=2 delims=-" %%i in ('echo %_range%') do set _end=%%i +if /i %_start% GTR %images% echo.&echo Range Start is higher than available indexes&echo.&PAUSE&goto :ESD4 +if /i %_end% GTR %images% echo.&echo Range End is higher than available indexes&echo.&PAUSE&goto :ESD4 +if /i %_start% EQU %_end% echo.&echo Range Start and End are equal. Use option 3 of main menu to export single index&echo.&PAUSE&goto :ESDMENU + +cls +IF EXIST "%CD%\install.wim" ( +ECHO =============================================================================== +ECHO. An install.wim file is already present in the current folder. +ECHO =============================================================================== +ECHO. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) +ECHO =============================================================================== +Echo Exporting ESD Index %_start% to a new install.wim file... +ECHO =============================================================================== +mkdir temp +dism /Quiet /Capture-Image /ImageFile:install.wim /CaptureDir:.\temp /Name:container /Compress:max /CheckIntegrity +rmdir /s /q temp +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:%_start% /DestinationImageFile:install.wim /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +dism /Quiet /Delete-Image /ImageFile:install.wim /Index:1 /CheckIntegrity + +set /a _start+=1 +for /L %%i in (%_start%, 1, %_end%) do ( +ECHO. +ECHO =============================================================================== +Echo Exporting ESD Index %%i to install.wim file... +ECHO =============================================================================== +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:%%i /DestinationImageFile:install.wim /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +) +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT + +:WIMMENU +cls +ECHO =============================================================================== +ECHO. Detected WIM file contains %images% indexes: +ECHO. +for /L %%i in (1, 1, %images%) do ( +ECHO. %%i. !name%%i! +) +ECHO. +ECHO =============================================================================== +ECHO. Options: +ECHO =============================================================================== +ECHO. 1 - Export 1st index +ECHO. 2 - Export all indexes +ECHO. 3 - Export selected single index +ECHO. 4 - Export selected range of indexes +ECHO =============================================================================== +ECHO. Press 'Q' to Quit +ECHO =============================================================================== + +choice /c 1234q /n /m "Choose a menu option, or Q to quit: " +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP%==1 GOTO :WIM1 +IF %ERRORTEMP%==2 GOTO :WIM2 +IF %ERRORTEMP%==3 GOTO :WIM3 +IF %ERRORTEMP%==4 GOTO :WIM4 +IF %ERRORTEMP%==5 GOTO :QUIT +GOTO :MAINMENU + +:WIM1 +cls +IF EXIST "%CD%\install.esd" ( +ECHO =============================================================================== +ECHO. An install.esd file is already present in the current folder. +ECHO =============================================================================== +ECHO. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) +ECHO =============================================================================== +Echo Exporting WIM Index 1 to a new install.esd file... +ECHO =============================================================================== +echo. +echo *** This will require some time, high CPU and Disk usage, please be patient *** +echo. +dism /export-image /sourceimagefile:"%WIMFILE%" /Sourceindex:1 /destinationimagefile:install.esd /compress:recovery /checkintegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT + +:WIM2 +cls +IF EXIST "%CD%\install.esd" ( +ECHO =============================================================================== +ECHO. An install.esd file is already present in the current folder. +ECHO =============================================================================== +ECHO. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) +ECHO =============================================================================== +Echo Exporting WIM Index 1 to a new install.esd file... +ECHO =============================================================================== +echo. +echo *** This will require some time, high CPU and Disk usage, please be patient *** +echo. +dism /Export-Image /SourceImageFile:"%WIMFILE%" /Sourceindex:1 /DestinationImageFile:install.esd /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) + +if "%images%"=="1" ( +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) + +for /L %%i in (2, 1, %images%) do ( +ECHO. +ECHO =============================================================================== +Echo Exporting WIM Index %%i to install.esd file... +ECHO =============================================================================== +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:%%i /DestinationImageFile:install.esd /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +) +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT + +:WIM3 +cls +set _index= +ECHO =============================================================================== +ECHO. Detected WIM file contains %images% indexes: +ECHO. +for /L %%i in (1, 1, %images%) do ( +ECHO. %%i. !name%%i! +) +ECHO. +ECHO =============================================================================== +ECHO. Enter desired index number to export +ECHO =============================================================================== +ECHO. Enter zero '0' to go back to Main Menu +ECHO =============================================================================== +set /p _index= ^> +if /i "%_index%"=="0" goto :WIMMENU +if [%_index%]==[] goto :WIM3 +if /i %_index% GTR %images% echo.&echo Selected number is higher than available indexes&echo.&PAUSE&goto :WIM3 + +cls +IF EXIST "%CD%\install.esd" ( +ECHO =============================================================================== +ECHO. An install.esd file is already present in the current folder. +ECHO =============================================================================== +ECHO. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) +ECHO =============================================================================== +Echo Exporting WIM Index %_index% to a new install.esd file... +ECHO =============================================================================== +echo. +echo *** This will require some time, high CPU and Disk usage, please be patient *** +echo. +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:%_index% /DestinationImageFile:install.esd /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT + +:WIM4 +cls +set _range= +set _start= +set _end= +ECHO =============================================================================== +ECHO. Detected WIM file contains %images% indexes: +ECHO. +for /L %%i in (1, 1, %images%) do ( +ECHO. %%i. !name%%i! +) +ECHO. +ECHO =============================================================================== +ECHO. Enter desired Range of indexes to export: Start-End +ECHO. Example: 2-4 or 1-3 or 3-4 +ECHO =============================================================================== +ECHO. Enter zero '0' to go back to Main Menu +ECHO =============================================================================== +set /p _range= ^> +if /i "%_range%"=="0" goto :WIMMENU +if [%_range%]==[] goto :WIM4 +for /f "tokens=1 delims=-" %%i in ('echo %_range%') do set _start=%%i +for /f "tokens=2 delims=-" %%i in ('echo %_range%') do set _end=%%i +if /i %_start% GTR %images% echo.&echo Range Start is higher than available indexes&echo.&PAUSE&goto :WIM4 +if /i %_end% GTR %images% echo.&echo Range End is higher than available indexes&echo.&PAUSE&goto :WIM4 +if /i %_start% EQU %_end% echo.&echo Range Start and End are equal. Use option 3 of main menu to export single index&echo.&PAUSE&goto :WIMMENU + +cls +IF EXIST "%CD%\install.esd" ( +ECHO =============================================================================== +ECHO. An install.esd file is already present in the current folder. +ECHO =============================================================================== +ECHO. +echo Press any key to exit. +pause >nul +GOTO :QUIT +) +ECHO =============================================================================== +Echo Exporting WIM Index %_start% to a new install.esd file... +ECHO =============================================================================== +echo. +echo *** This will require some time, high CPU and Disk usage, please be patient *** +echo. +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:%_start% /DestinationImageFile:install.esd /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) + +set /a _start+=1 +for /L %%i in (%_start%, 1, %_end%) do ( +ECHO. +ECHO =============================================================================== +Echo Exporting WIM Index %%i to install.esd file... +ECHO =============================================================================== +dism /Export-Image /SourceImageFile:"%WIMFILE%" /SourceIndex:%%i /DestinationImageFile:install.esd /compress:recovery /CheckIntegrity +SET ERRORTEMP=%ERRORLEVEL% +IF %ERRORTEMP% NEQ 0 (ECHO.&Echo Errors were reported during dism export.&PAUSE&GOTO :QUIT) +) +echo. +echo Done. +echo. +echo Press any key to exit. +pause >nul +GOTO :QUIT + +:QUIT \ No newline at end of file diff --git a/Powershell/From Evernote/Intune.ps1 b/Powershell/From Evernote/Intune.ps1 new file mode 100644 index 0000000..a768e17 --- /dev/null +++ b/Powershell/From Evernote/Intune.ps1 @@ -0,0 +1,267 @@ +param([switch]$Elevated) +function Check-Admin { +$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent()) +$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) +} +if ((Check-Admin) -eq $false)  { +if ($elevated) +{ +# could not elevate, quit +} +  +else { +  +Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition)) +} +exit +} +function Write-ProgressHelper { + param ( + [int]$StepNumber, + [string]$Message + ) + + Write-Progress -Activity 'PSC Update Readiness 2019' -Status $Message -PercentComplete (($StepNumber / $steps) * 100) +} + +$script:steps = ([System.Management.Automation.PsParser]::Tokenize((gc "$PSScriptRoot\$($MyInvocation.MyCommand.Name)"), [ref]$null) | where { $_.Type -eq 'Command' -and $_.Content -eq 'Write-ProgressHelper' }).Count + +$stepCounter = 0 + +Write-ProgressHelper -Message 'Checking For Previous Run' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 2.5 +$ErrorActionPreference="SilentlyContinue" +$maxRepeat = 10 +$Organisation = "PSC" +$ThisPC = ($env:COMPUTERNAME + $env:username) +$freespaceError = ("$env:COMPUTERNAME only has $spacegb GB Free and cannot continue 1903 install") +$TeamViewerFileName = "c:\teamviewer_install\TeamviewerHost.msi" +$InTuneLog = "c:\InTune_Log\$env:COMPUTERNAME.log" +$InTuneFolder = "c:\InTune_Log\*.*" +$InTune_Folder = "c:\InTune_Log\" +$ts = New-TimeSpan -Hours 2 +function not-exist { -not (Test-Path -Path $TeamViewerFileName) } +#Set-Alias !exist not-exist -Option "Constant, AllScope" +#Set-Alias exist Test-Path -Option "Constant, AllScope" +Add-Type -AssemblyName System.Windows.Forms | Out-Null +Stop-Transcript | out-null +$ErrorActionPreference = "Continue" +If (-not(Test-Path -Path $InTune_Folder)) { +mkdir $InTune_Folder } +filter timestamp {"$(Get-Date -Format G): $_"} + +if (Test-Path -Path $InTuneLog) { +Remove-Item $InTuneLog -ErrorAction SilentlyContinue +Remove-Item $InTune_Folder\$env:COMPUTERNAME.zip -Force -ErrorAction SilentlyContinue +Remove-Item c:\InTune_Log\"$env:COMPUTERNAME"_Transcript.log -ErrorAction SilentlyContinue +Remove-Item c:\InTune_Log\"$env:COMPUTERNAME".csv -ErrorAction SilentlyContinue +Remove-Item c:\InTune_Log\$env:Computername-Bitlocker-Recovery-key.txt -ErrorAction SilentlyContinue +Start-Sleep -Seconds 1.5} +Else +{ +# Move On +} +Start-Transcript -path c:\InTune_Log\"$env:COMPUTERNAME"_Transcript.log +Write-ProgressHelper -Message 'Checking For Teamviewer' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 2.5 +############################################################################ +# Teamviewer Start +############################################################################ +#Get Teamviewer +if (-not (Test-Path -Path $TeamViewerFileName)) { +mkdir c:\teamviewer_install +$url = "https://onedrive.live.com/download?cid=77FB0E4F642F10B7&resid=77FB0E4F642F10B7%21273176&authkey=AOouFE3GDGRSHIc" +$output = "c:\teamviewer_install\TeamviewerHost.msi" +$start_time = Get-Date + +$wc = New-Object System.Net.WebClient +$wc.DownloadFile($url, $output) +Write-Host "Temaviewer Downloaded" +msiexec.exe /i "c:\teamviewer_install\TeamviewerHost.msi" /qn CUSTOMCONFIGID=6988pev APITOKEN=6581446-B1aEz7nIk9k92p4G7C1R ASSIGNMENTOPTIONS="--grant-easy-access" +Write-Host "Teamviewer Installed" +} +Else +{ +Write-Host "TeamViewer Already Installed" +} + +############################################################################# +# Teamviewer End +############################################################################# +Write-ProgressHelper -Message 'Checking Your PC Integrity - Integrity Is Important You Know' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 5 +############################################################################## +# Computer Sanity Check End +############################################################################## + + # Power Connect Check + +#Function Check-BatteryState { +#param($Laptop=$env:computername) +#$Bstatus = ((Get-WmiObject -Class Win32_Battery).BatteryStatus) +#} +$Bstatus = ((Get-WmiObject -Class Win32_Battery).BatteryStatus) +if($Bstatus) { + switch ($Bstatus) + { + 1 { "Battery is discharging" } + 2 { "The system has access to AC so no battery is being discharged. However, the battery is not necessarily charging." } + 3 { "Fully Charged" } + 4 { "Low" } + 5 { "Critical" } + 6 { "Charging" } + 7 { "Charging and High" } + 8 { "Charging and Low" } + 9 { "Charging and Critical " } + 10 { "Unknown State" } + 11 { "Partially Charged" } + + } +} + +If ($BStatus -eq 2) { +# Move On +} + +Else { + [System.Windows.Forms.MessageBox]::Show("You Need To Be Connected To The Power Adapter! Please re run from Software Center when power is avalable. Exiting...", $Organisation, + [System.Windows.Forms.MessageBoxButtons]::OK, + [System.Windows.Forms.MessageBoxIcon]::ERROR) + + } + + + # Power Connect Check End +#---------------------------------------------------------------------------- +Write-ProgressHelper -Message 'Checking Your Free Drive Space - You Should Be Saving Everything To The Cloud Anyway' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 5 + +#---------------------------------------------------------------------------- + # Free Space Check Start + +$disk = Get-WMIObject Win32_Logicaldisk -filter "deviceid='$((Get-WMIObject Win32_OperatingSystem -computername $env:COMPUTERNAME).systemdrive)'" -ComputerName $env:COMPUTERNAME +$freespace = ($disk.FreeSpace) +$spacegb = [math]::Round($disk.Freespace/1GB,2) + + # Free Space Check End +#---------------------------------------------------------------------------- +Write-ProgressHelper -Message 'Checking Your PC Is Secure - Safety First!' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 5 +#---------------------------------------------------------------------------- + # Bitlocker Status +Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force +$blockerstatus = (Get-BitlockerVolume -MountPoint "C:") + +#---------------------------------------------------------------------------- +Write-ProgressHelper -Message 'Checking For PSC Admin' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 5 +#---------------------------------------------------------------------------- + # PSC Admin User Check Start + + +$UserPassword = ConvertTo-SecureString "Restore99!" -AsPlainText -Force +$psclocaladmin = $null +If ($psclocaladmin = Get-LocalUser pscadmin) +{ + Add-LocalGroupMember -Group "Administrators" -Member "pscadmin" + Enable-LocalUser -Name "pscadmin" +} +Else +{ +# If (!$psclocaladmin) + New-LocalUser "pscadmin" -Password $UserPassword -FullName "PSC Admin" -Description "PSC Admin Account" -AccountNeverExpires -PasswordNeverExpires + Add-LocalGroupMember -Group "Administrators" -Member "pscadmin" + Enable-LocalUser -Name "pscadmin" + } + + + # PSC Admin User Check End +#---------------------------------------------------------------------------- +Write-ProgressHelper -Message 'Creating Restore Point - We Like To Play It Safe!' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 10 +#---------------------------------------------------------------------------- + # System Restore Check Start + +Enable-ComputerRestore -Drive "C:\" +Checkpoint-Computer -Description "New Intune Setup 2019" -RestorePointType MODIFY_SETTINGS + + # System Restore Check End +#---------------------------------------------------------------------------- + +############################################################################## +# Computer Sanity Check End +############################################################################## +Write-ProgressHelper -Message 'Checking For Errors - Its Windows 10, As If There Would Be Errors!?' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 5 + +# Errors + +If($freespace -lt 32212254720 ) { + $freespaceError | Format-Table | Out-File -append "c:\InTune_Log\$env:COMPUTERNAME.log" | Write-Output +} +else { + # No Error To See Here, Keep Moving! +} + + +If ($blockerstatus.protectionstatus -ne "On") { + Enable-BitLocker -MountPoint C: -UsedSpaceOnly -SkipHardwareTest -RecoveryKeyPath "c:\InTune_Log\" -RecoveryKeyProtector + manage-bde -protectors -get c: >> c:\InTune_Log\$env:Computername-Bitlocker-Recovery-key.txt + ("BitLocker Was Off") | Format-Table | Out-File -append "c:\InTune_Log\$env:COMPUTERNAME.log" | Write-Output + +} +Else +{ + manage-bde -protectors -get c: >> c:\InTune_Log\$env:Computername-Bitlocker-Recovery-key.txt +} +Start-Sleep -Seconds 1.5 +if ($BStatus -ne 2) +{ + ("$env:username Did Not Plug In To Mains") | Format-Table | Out-File -append "c:\InTune_Log\$env:COMPUTERNAME.log" | Write-Output +} + +# AutoPilot Hardware Hash +Install-Script -Name Get-WindowsAutoPilotInfo -Force +Start-Sleep -Seconds 3 +Get-WindowsAutoPilotInfo.ps1 -append -OutputFile "c:\InTune_Log\$env:COMPUTERNAME.csv" +Start-Sleep -Seconds 2.5 + +Stop-Transcript + +# Fail +$LogsExist = (Test-Path $InTuneLog) +Write-ProgressHelper -Message 'Sending Data To PSC IT' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 4 +if (Test-Path $InTuneLog) +{ +$psclocaladmin | Format-Table | Out-File -append "c:\InTune_Log\$env:COMPUTERNAME.log" | Write-Output +("BitLocker Was Off, It has now been switched on by InTune Script. Please try again in an hour") | Format-Table | Out-File -append "c:\InTune_Log\$env:COMPUTERNAME.log" | Write-Output +Compress-Archive -Path $InTuneFolder -DestinationPath $InTune_Folder\$env:COMPUTERNAME.zip +Start-Sleep -Seconds 5 +Send-MailMessage -from "$env:username" -to "IT" -Subject "AAD Intune Upgrade Report Fail $env:computername" -Body "$env:COMPUTERNAME InTune Logs" -Attachments "$InTune_Folder\$env:COMPUTERNAME.zip" -SmtpServer "pscconsulting-com.mail.protection.outlook.com" +curl "https://onedrive.live.com/download?cid=77FB0E4F642F10B7&resid=77FB0E4F642F10B7%21273301&authkey=AEReiJb0-g1gGqc" -o "$InTune_Folder\sendfile.ps1" +Invoke-Expression (($InTune_Folder)+"\sendfile.ps1") +Remove-Item $InTune_Folder\sendfile.ps1 -Force -ErrorAction SilentlyContinue + [System.Windows.Forms.MessageBox]::Show("The PSC IT Update Readiness Tool Has Completed Its Task. All Details Have Been Sent To PSC IT.", $Organisation, + [System.Windows.Forms.MessageBoxButtons]::OK, + [System.Windows.Forms.MessageBoxIcon]::INFORMATION) +} +Else +{ +("BitLocker Was Already On") | Format-Table | Out-File -append "c:\InTune_Log\$env:COMPUTERNAME.log" | Write-Output +$psclocaladmin | Format-Table | Out-File -append "c:\InTune_Log\$env:COMPUTERNAME.log" | Write-Output +("$env:COMPUTERNAME has $spacegb GB Free") | Format-Table | Out-File -append "c:\InTune_Log\$env:COMPUTERNAME.log" | Write-Output +Compress-Archive -Path $InTuneFolder -DestinationPath $InTune_Folder\$env:COMPUTERNAME.zip +Start-Sleep -Seconds 5 +Send-MailMessage -from "$env:username" -to "IT" -Subject "AAD Intune Upgrade Report Success $env:computername" -Body "$env:COMPUTERNAME InTune Logs" -Attachments "$InTune_Folder\$env:COMPUTERNAME.zip" -SmtpServer "pscconsulting-com.mail.protection.outlook.com" +curl "https://onedrive.live.com/download?cid=77FB0E4F642F10B7&resid=77FB0E4F642F10B7%21273301&authkey=AEReiJb0-g1gGqc" -o "$InTune_Folder\sendfile.ps1" +Invoke-Expression (($InTune_Folder)+"\sendfile.ps1") +Remove-Item $InTune_Folder\sendfile.ps1 -Force -ErrorAction SilentlyContinue + + [System.Windows.Forms.MessageBox]::Show("The PSC IT Update Readiness Tool Has Completed Its Task. All Details Have Been Sent To PSC IT.", $Organisation, + [System.Windows.Forms.MessageBoxButtons]::OK, + [System.Windows.Forms.MessageBoxIcon]::INFORMATION) +} + +Write-ProgressHelper -Message 'Checkup Complete - Thanks For Playing' -StepNumber ($stepCounter++) +Start-Sleep -Seconds 3 \ No newline at end of file diff --git a/Powershell/From Evernote/PSC InTune Readiness Script Call Batch files/Intune-run-first.bat b/Powershell/From Evernote/PSC InTune Readiness Script Call Batch files/Intune-run-first.bat new file mode 100644 index 0000000..4e5e72d --- /dev/null +++ b/Powershell/From Evernote/PSC InTune Readiness Script Call Batch files/Intune-run-first.bat @@ -0,0 +1,28 @@ +@echo off +:: BatchGotAdmin +::------------------------------------- +REM --> Check for permissions +>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" + +REM --> If error flag set, we do not have admin. +if '%errorlevel%' NEQ '0' ( + echo Requesting administrative privileges... + goto UACPrompt +) else ( goto gotAdmin ) + +:UACPrompt + echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" + set params = %*:"=" + echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" + + "%temp%\getadmin.vbs" + del "%temp%\getadmin.vbs" + exit /B + +:gotAdmin + pushd "%CD%" + CD /D "%~dp0" +::-------------------------------------- + +powershell -command "& {Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force}" +powershell ./Intune.ps1 diff --git a/Powershell/From Evernote/Remote Enable BitLocker files/Bitlocker.zip b/Powershell/From Evernote/Remote Enable BitLocker files/Bitlocker.zip new file mode 100644 index 0000000000000000000000000000000000000000..0092b91d1943a63aed1007161692476416ddb831 GIT binary patch literal 13261 zcma)jb8II-xNU9Q*xI(+t-H0|Uu|34Zq2Q2+qP}n{na+_-k1Ac?#s&66RWBldeFG_4v>tYc5m-&q_><9V|ybaK@*@WoWc zACU!M;MJqd2MMo-Kq!;IQ@~P8flXnH=EDAx3J7X`fG@Npfn8hQz0P#Lp6rY}6n;M^ z-no8ujhgN-Zv$p~Pq#g1zq50O#%v-WfjI2X1jB>)L+&>~Z@)Mb`TMvU-1M18b~l~X zBv#v3;bqEb@8K?_vKue#dC+HZvhFzw*i07>jJdRSnUnC_l0Ssh*YC>~#%v?~W*h>& zUiI8PtK23IC{LuO0Fgw!gym1@OY=F|f^n9>Aqc{t9 zK_8j;9Rv;K@PWwe_1wS$<$$r+x1XGyqy;(SyZ0T&PWqDfZX2ouw#*D{Nb{WO9r*sk z_pI~y-gt5Xrh`RQ?oxUxk%v$Hfiu3qL1!U%N0CRjix3v2L1w!b1;1qRagYeEN|&EL z4?dD69JFhyy6)xGYqV4{5M2fYb0{!A`MTjR;TXcdFJ-JWP|fYhr7lsz)y>7N!y4tn z7)#t39FxV>N0l_@o%!qGB&%vxPhiE*{?;-ER?}C1^Nd%;J5`*9KSAMb-S`CqE0(&j zM3_3HAMseg%q(v$PMDjQ;re++Y8i*j!*|}jFx?bCx5dF!%=J)HdOoAfKq(GwYybT z@0aH`p<3Qs#N~U6hJq7KH5l#|BU{;-v~oOyp}S{wI_w1=_ooJnbK2xPtN_u>Yeowr z2tbWb19{@!(hI!kU)lq|9lla6n!hUsFGe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N7g3Fz%fxXrO4<^6k^_0<0UbZi=i zsGnMd@*~BLFJjKk_IaFxW@hU4Sa__*l}UL!Cq@ruc~}1gk)}SI21Wb6Fgp-PqJ8`RBDbKmMdQJ#|v9 zG`UAxHu<%qYxo{B#Y3g|o6|h2J@Shs|NC`SkZpfw)XRzMV+Qy=F!K$m_sfe~Qj z60JOEwZV+x%k@Ic2*x#5n$_qF&ra`JUl+<~J1>YJClXg<%TQk^?Uc^EY@b6As=VB! zYFInd1ti!yc*oT$62=tAi5hVbC#>kE<(jf))FJ;Gh5d8%fkzTU^;dnAQ;`}R@7Gk- zk<2=C>ZnBT>)|1SRO4G+dxilMc4P;2gZFuDH}?#VX+LGF*qvEuJS0=>4mkqv!t%Wi zs6|u@Jp@BvK3}k8kZyn~5^cM9?j^T0&JCE?T%N`*miXeI>wBG(Xs=mh@Eah?Fq%Jy z1!0P*zS?kJNh<#fxnr%EeVS%cA-zR$)OZhS*0@UyR9}gX(o>6E}m%$@UZ`oVw zC)$F#qE>%-bu0aUI3xSkmn(*ulsD~8ZqP{+K{4OnzP!37CY`j`HCxN_3JCF9SXtP1 zX+K!XF^<8L*~b&G1Nls%#Yifrk>hf}a9P8$FJSUxh?_LuQzewo4WX8c`;2$k)576!Ed7&VJkb1e<=(_U|$&%7TIsgZ#hDE#&{i@}G_5e~tgc>H_y)6QCeCARrI4;2e#M zpdidXIF}8Jpd_@YV4VN(e<%2#TKw+>_5VCI|KG~|zo? + + + + + + + + + + + + + + + + + + + + + + + + +

+ Robocopy with file exclude +

Robocopy with file exclude
20 July 2018
10:42

robocopy "\\192.168.11.7\Projects\Baywa\Hughenden Solar Farm PSCAD" "c:\Baywa\Hughenden Solar Farm PSCAD" /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF *.out
 
Created with Microsoft OneNote 2016.
+ + diff --git a/Powershell/From Evernote/Stop organisation asking to manage device win10-11.ps1 b/Powershell/From Evernote/Stop organisation asking to manage device win10-11.ps1 new file mode 100644 index 0000000..4a6adbb --- /dev/null +++ b/Powershell/From Evernote/Stop organisation asking to manage device win10-11.ps1 @@ -0,0 +1,11 @@ +#Setting registry key to block AAD Registration to 3rd party tenants. +$RegistryLocation = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WorkplaceJoin\" +$keyname = "BlockAADWorkplaceJoin" +#Test if path exists and create if missing +if (!(Test-Path -Path $RegistryLocation)){ +Write-Output "Registry location missing. Creating" +New-Item $RegistryLocation | Out-Null +} +#Force create key with value 1 +New-ItemProperty -Path $RegistryLocation -Name $keyname -PropertyType DWord -Value 1 -Force | Out-Null +Write-Output "Registry key set" \ No newline at end of file diff --git a/Powershell/From Evernote/Teamviewer Install files/Install-Teamviewer.ps1 b/Powershell/From Evernote/Teamviewer Install files/Install-Teamviewer.ps1 new file mode 100644 index 0000000..1d064b2 --- /dev/null +++ b/Powershell/From Evernote/Teamviewer Install files/Install-Teamviewer.ps1 @@ -0,0 +1,54 @@ +<# + .Synopsis Detects, downloads, installs and configures the latest version of TeamViewer. + .Notes + Requires TeamViewer 14. + + TeamViewer Installation Documentation + https://community.teamviewer.com/t5/Knowledge-Base/Mass-deployment-improvements/ta-p/39639 +#> +$ConfigurationID = "64uyck9" +$ApiToken = "6615740-y9LI6bdNq5QtaDtiGVTN" +$ComputerName = $ENV:COMPUTERNAME + +if (Test-Path 'C:\Program Files (x86)\TeamViewer\TeamViewer.exe') { + Write-Host 'Team Viewer already installed.' + return +} + +Write-Host 'Installing TeamViewer.' + +Write-Host 'Downloading TeamViewer Host Setup.' +$SetupFilePath = Join-Path $ENV:TEMP "TeamViewer_Host_Setup-idc$($ConfigurationID).exe" + +$response = Invoke-RestMethod "https://get.teamviewer.com/$ConfigurationID" +$json = '{}' +if ($response -match 'configId = "(?[^"]+).*\n.*version = "(?[^"]+).*\n.*isCustomModule = (?[^"]+);.*\n.*subdomain = "(?[^"]+)(?)' ) { + $Matches.Remove(0) + $Matches['IsCustomModule'] = if ($Matches['IsCustomModule'] -eq 'true') { $true } else { $false } + $json = [PsCustomObject]$Matches | ConvertTo-Json +} +else { + throw 'Expected JSON values not found in initial HTML page' +} + +$DownloadUri = Invoke-RestMethod -Uri 'https://get.teamviewer.com/api/CustomDesign' -Method Post -Body $json -ContentType 'application/json' +Invoke-WebRequest -Uri $DownloadUri -OutFile $SetupFilePath + + +if (-not (Test-Path $SetupFilePath)) { + throw 'TeamViewer_Setup.exe failed to download.' +} + +Write-Host 'Installing.' +& $SetupFilePath /S | Write-Output +Write-Debug "$SetupFilePath LastExitCode = $LASTEXITCODE" + +Write-Host 'Configuring' +& "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" assign --api-token $ApiToken --grant-easy-access --reassign --alias $ComputerName | Write-Output +Write-Debug "TeamViewer.exe assign LastExitCode = $LASTEXITCODE" + +Write-Host 'Cleaning up.' +$SetupTempFolder = Join-Path $ENV:TEMP 'TeamViewer' +$SetupFilePath, $SetupTempFolder | Remove-Item -Recurse + +Write-Host 'Complete.' \ No newline at end of file diff --git a/Powershell/From Evernote/Teamviewer Install files/TeamviewerInstall.ps1 b/Powershell/From Evernote/Teamviewer Install files/TeamviewerInstall.ps1 new file mode 100644 index 0000000..77f0ad2 --- /dev/null +++ b/Powershell/From Evernote/Teamviewer Install files/TeamviewerInstall.ps1 @@ -0,0 +1,51 @@ +param([switch]$Elevated) +function Check-Admin { +$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent()) +$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) +} +if ((Check-Admin) -eq $false)  { +if ($elevated) +{ +# could not elevate, quit +} +  +else { +  +Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition)) +} +exit +} +$TempInstallDir = "c:\teamviewer_install\" +if (Test-Path $TempInstallDir) { +Remove-Item $TempInstallDir -Recurse -Force +} +else +{ +Write-Host "Install Start" +} +$TeamViewerFileName = "C:\Program Files (x86)\TeamViewer\TeamViewer.exe" +$TeamViewer64FileName = "C:\Program Files\TeamViewer\TeamViewer.exe" + + +function not-exist { -not (Test-Path -Path $TeamViewer64FileName) } +function not-exist { -not (Test-Path -Path $TeamViewerFileName) } +if (-not (Test-Path -Path $TeamViewerFileName)) {} +if (-not (Test-Path -Path $TeamViewer64FileName)) { +mkdir c:\teamviewer_install +$url = "https://download.teamviewer.com/download/version_15x/TeamViewer_MSI32.zip" +$output = "c:\teamviewer_install\TeamviewerHost.zip" +$tvdir = "c:\teamviewer_install" +$start_time = Get-Date + +$wc = New-Object System.Net.WebClient +$wc.DownloadFile($url, $output) +Write-Host "Teamviewer Downloaded" +sleep 3 +Expand-Archive -LiteralPath $output -DestinationPath $tvdir -Force +msiexec.exe /i "c:\teamviewer_install\Host\Teamviewer_Host.msi" /qn CUSTOMCONFIGID=6988pev APITOKEN=6581446-B1aEz7nIk9k92p4G7C1R ASSIGNMENTOPTIONS="--grant-easy-access" +Write-Host "Teamviewer Installed" +} +Else +{ +Write-Host "TeamViewer Already Installed" +} \ No newline at end of file diff --git a/Powershell/From Evernote/Uninstall-IntuneClient.ps1 b/Powershell/From Evernote/Uninstall-IntuneClient.ps1 new file mode 100644 index 0000000..dc16948 --- /dev/null +++ b/Powershell/From Evernote/Uninstall-IntuneClient.ps1 @@ -0,0 +1,40 @@ +function Get-ServiceId { + #Set the registry path containing the service ID + $RegistryPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OnlineManagement" + try { + #Get all the names of the items in the registry location + $RegistryItems = (Get-ChildItem -Path Registry::$RegistryPath -ErrorAction Stop).Name + #Loop through all the results + foreach ($RegistryItem in $RegistryItems) { + #Find the result that starts with the registry location followed by the first sign of a GUID + if ($RegistryItem.StartsWith("$RegistryPath\{")) { + #Replace the registry location with nothing to get the GUID + $ServiceId = $RegistryItem.Replace("$RegistryPath\","") + break + } + } + return $ServiceId + } + catch { + Write-Output "The Microsoft Intune client is not installed" + } +} + +function Start-Uninstall { + param ( + [parameter(Mandatory=$true)]$ServiceId + ) + try { + #Set the ProvisioningUtil location and parameters + $ProvisioningUtilPath = "C:\Program Files\Microsoft\OnlineManagement\Common" + $ProvisioningUtilExecutable = "ProvisioningUtil.exe" + $ProvisioningUtilArguments = "/UninstallClient /ServiceId $ServiceId /TaskName 'tempTask' /SubEventId 16" + #Trigger the uninstall of the Microsoft Intune client + Start-Process -FilePath "$($ProvisioningUtilPath)\$($ProvisioningUtilExecutable)" -ArgumentList $ProvisioningUtilArguments -Wait -PassThru + } + catch { + Write-Output "Failed to trigger the uninstall of the Microsoft Intune client" + } +} + +Start-Uninstall (Get-ServiceId) \ No newline at end of file