-1

I created a new user with the following PowerShell command

New-LocalUser -Name "PVUser" -Description "Profile for PVUser" -Password (ConvertTo-SecureString "Password1" -AsPlainText -Force)

I then try to sign in and interact with this user but I cannot find this this user anywhere. Is it because I did not add it to a group?

I have no issues when I run this script to create an administrator account.

# Create User account and add it to Administrators group
$UserPassword = ConvertTo-SecureString "1234" -AsPlainText -Force
$NewAccountUser = New-LocalUser -Name "User" -Description "Local Admin User" -Password $UserPassword
Add-LocalGroupMember -Group "Administrators" -Member $NewAccountUser

Unfortunately, the first script I ran seems to create the profile but I cannot run a script to delete the file or erase through the GUI.

User Profiles

Below are the user profiles I can interact with through the GUI.

User Profiles I can interact with through the GUI Below are the available profiles that can be modified/deleted. Using advanced system properties. User Profiles in System Properties

2 Answers 2

1

First, make a new user, member of Administrators, and check that you can log in as such.

Second,.right click on This PC, and select Properties. In the right hand window, select Advanced System Settings. Select that.

First tab is Computer Name. Click on User Profiles (Settings).

Select the profile you wish to delete and delete it.

Remember the new user you made MUST be a member of the Admin group.

Make this work first and then make a test profile to try scripts.

There are System Profile that you did not set up that cannot be removed. Just leave those.

Clarifying Screen shots below.

(1) Local Users and Groups.

Users in Local Users and Groups

(2) Advanced System Settings

enter image description here

You can see that there are System Users

10
  • I do not want the new user to be in the Admin group. I want each user profile to have different levels of access on the PC. Commented Jun 3 at 18:09
  • You need an overall admin user to delete profiles. So try what I suggest. Done this many times.
    – anon
    Commented Jun 3 at 18:11
  • Yes but these profiles have already been made. I cannot get rid of them or modify them. Commented Jun 3 at 18:17
  • 1
    I added clarifying screen shots to show System Users
    – anon
    Commented Jun 3 at 18:52
  • 1
    I have not seen any way in workstation Windows to do that
    – anon
    Commented Jun 3 at 19:06
2

To remove a user profile via a command, I can list the following two methods:

  • In an elevated CMD, run net user User /DELETE.
    Try first the command net user to see if it lists this user profile.

  • In elevated PowerShell run :

    Get-CimInstance -ClassName Win32_UserProfile | ?{$_.LocalPath -like "C:\Users\User"} | Remove-CimInstance -Confirm:$false
    

    Try it first without the Remove-CimInstance to be sure that it gets the right account.

I would suggest before running automated scripts to remove user profiles, to take precautions and verify everything. Make also at least a System Restore point as backup.

1
  • this is a VM in Hyper-V I made for testing this. Commented Jun 3 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .