I tried to use PowerShell script via Intune that remove my user from Windows Endpoint using powershell command Remove-LocalUser -Name “myuser”. It was not working, just because: , error = Remove-LocalUser : The term ‘Remove-LocalUser’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:Program Files (x86)Microsoft Intune Management ExtensionPoliciesScripts5b2518c-c36d-4a05-84f7-6fac956d4cc6_c293361b-b3d3-48d9-8aca-f8ccf0a11330.ps1:1 char:1 + Remove-LocalUser -Name “myuser” + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Remove-LocalUser:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException So the workaround is using this: “net user myuser /DELETE”|cmd All script: $op = Get-LocalUSer | where-Object Name -eq “myuser” | Measure if ($op.Count -eq 0) { Write-Host “No User to Remove” } else { “net user myuser /DELETE”|cmd Write-Host “User myuser has been Removed” }
Month: October 2020
Recovery Services vault – How to Disable Backup, Move to a new Recovery Services vault
1. Stop Backup – without Erasing Data2. Disable Soft Deletion in Recovery Service VaultId 3. Execute Script: $RG=backup-mig$Vault=backup-mig$VMName=medicareiisql$vault = Get-AzRecoveryServicesVault -ResourceGroupName $RG -Name $Vault$Container = Get-AzRecoveryServicesBackupContainer -ContainerType AzureVM -Status Registered -VaultId $vault.ID -FriendlyName $VMName$BackupItem = Get-AzRecoveryServicesBackupItem -Container $Container -WorkloadType AzureVM -VaultId $vault.IDDisable-AzRecoveryServicesBackupProtection -Item $BackupItem -VaultId $vault.ID -RemoveRecoveryPoints -Force