

Write-host "Enrolling $ env:USERNAME with Serial = $serial " Start-Process msiexec.exe -Wait -ArgumentList '/I installer-1.0.0.55-圆4.msi /qn ' Write-host "Installing Device Managment Compatibility Tool.

Start-process -Wait "msiexec " -arg "/X $uninstallString32 /qn " Write-host "Uninstalling 32bit AirwatchAgent. Write-host " $uninstallString32 GUID found " Write-host "Issues with uninstalling 64bit airwatch agent " Start-process -Wait "msiexec " -arg "/X $uninstallString64 /qn " Write-host "Uninstalling 64bit AirwatchAgent. Write-host " $uninstallString64 GUID found " $uninstallString64 = ( Get-ItemProperty HKLM:\Software\wow6432node\Microsoft\Windows\CurrentVersion\Uninstall\ * | where-Object ).PSChildName Write-host "Checking for existing Airwatch install. Write-host "Non-Compliant Enrollment, enrolled as $val2, Serial = $serial "

If ( $val2 -eq " -or $val2 -eq " -or $val2 -eq $null) $val2 = ( Get-ItemProperty -Path $PATH2 -ErrorAction Silentl圜ontinue).UPN #This returns the email address of enrolled user $path2 = "HKLM:\SOFTWARE\Microsoft\Enrollments\ $val " #Now checking whether enrollment is with a real user or the staging user $val = ( Get-ItemProperty -Path $PATH -ErrorAction Silentl圜ontinue).PSChildname $PATH = "HKLM:SOFTWARE\Microsoft\Provisioning\OMADM\Accounts\* " Write-Host "Script version is: $version " Start-Transcript $scriptlogpath\ $scriptfilename If (( Test-Path $serverlogpath) -eq $false) If (( Test-Path $scriptlogpath) -eq $false) $AWAGENTLOGPATH = "C:\Temp\Logs\AirwatchEnrollment\ " $PASSWORD = "Win10 " #staging account password $USERNAME = "StagingWin10 " #staging account username $LGName = "Staging " #Organization group name of the staging OG $DeviceOwnershipType = "CS " #device ownership type $scriptfilename = " $ env:computername- $version.log " #local log file name $scriptlogpath = "C:\Temp\Logs\AirwatchEnrollment " #local path for logs #$pass = "" | ConvertTo-SecureString -AsPlainText -Force #log server password #$serverlogpath = "\$version" #UNC path for server log
