Showing error that “remove-localUser” is not recognised as the name of cmdlet…
\nI find this script from spicework<\/p>\n

Advertisement

clear
\n$hostdetail = Import-CSV C:\\Users\\jj\\Desktop\\Test\\hosts.csv<\/p>\n

Advertisement

ForEach ($item in $hostdetail)
\n{
\n$hostname = $($item.hostname)
\n$username = $($item.username)
\n$computer = $hostname<\/p>\n

#Test<\/span> network connection and Windows version on the remote desktop<\/p>\n

If ((!(Test-Connection -comp $computer -count 1 -quiet)) -Or ((Get-WmiObject -ComputerName $computer Win32_OperatingSystem -ea stop).Version -lt 6.0))
\n{
\nWrite-Warning “$computer is not accessible or The Operating System of the $computer is not supported.nClient: Vista and above<\/code>nServer: Windows 2008 and above.”
\n}
\nelse
\n{
\n$User = $username
\n$SB = {
\nRemove-LocalUser -InputObject $Using:User
\n}
\nInvoke-Command -ComputerName $computer -ScriptBlock $SB
\n}
\n}<\/p>","upvoteCount":5,"answerCount":6,"datePublished":"2021-08-09T10:07:42.000Z","author":{"@type":"Person","name":"catherine83","url":"https://community.spiceworks.com/u/catherine83"},"suggestedAnswer":[{"@type":"Answer","text":"

Showing error that “remove-localUser” is not recognised as the name of cmdlet…
\nI find this script from spicework<\/p>\n

clear
\n$hostdetail = Import-CSV C:\\Users\\jj\\Desktop\\Test\\hosts.csv<\/p>\n

ForEach ($item in $hostdetail)
\n{
\n$hostname = $($item.hostname)
\n$username = $($item.username)
\n$computer = $hostname<\/p>\n

#Test<\/span> network connection and Windows version on the remote desktop<\/p>\n

If ((!(Test-Connection -comp $computer -count 1 -quiet)) -Or ((Get-WmiObject -ComputerName $computer Win32_OperatingSystem -ea stop).Version -lt 6.0))
\n{
\nWrite-Warning “$computer is not accessible or The Operating System of the $computer is not supported.nClient: Vista and above<\/code>nServer: Windows 2008 and above.”
\n}
\nelse
\n{
\n$User = $username
\n$SB = {
\nRemove-LocalUser -InputObject $Using:User
\n}
\nInvoke-Command -ComputerName $computer -ScriptBlock $SB
\n}
\n}<\/p>","upvoteCount":5,"datePublished":"2021-08-09T10:07:42.000Z","url":"https://community.spiceworks.com/t/showing-error-on-following-powershell-script/807867/1","author":{"@type":"Person","name":"catherine83","url":"https://community.spiceworks.com/u/catherine83"}},{"@type":"Answer","text":"

@tfl<\/span>, @Testlink<\/a> - I am using 5.1 version of powershell<\/p>","upvoteCount":0,"datePublished":"2021-08-09T10:13:34.000Z","url":"https://community.spiceworks.com/t/showing-error-on-following-powershell-script/807867/2","author":{"@type":"Person","name":"catherine83","url":"https://community.spiceworks.com/u/catherine83"}},{"@type":"Answer","text":"

The module with that command is not available in 32 bit Powershell. Are you using 32 bit?<\/p>\n

\n
\n\n learn.microsoft.com<\/a>\n <\/header>\n\n
\n \n\n

Microsoft.PowerShell.LocalAccounts Module - PowerShell<\/a><\/h3>\n\n

This section contains the help topics for the Local Accounts cmdlets in Windows PowerShell. Note This module is not available in 32-bit PowerShell on a 64-bit system.<\/p>\n\n\n <\/article>\n\n

\n \n \n <\/div>\n\n
<\/div>\n<\/aside>\n","upvoteCount":1,"datePublished":"2021-08-09T11:13:36.000Z","url":"https://community.spiceworks.com/t/showing-error-on-following-powershell-script/807867/3","author":{"@type":"Person","name":"curlyd","url":"https://community.spiceworks.com/u/curlyd"}},{"@type":"Answer","text":"

It works here. Can you provide the output of $ PSVersiontable? And also the output of Get-module Local* -list<\/p>","upvoteCount":0,"datePublished":"2021-08-09T11:41:33.000Z","url":"https://community.spiceworks.com/t/showing-error-on-following-powershell-script/807867/4","author":{"@type":"Person","name":"DoctorDNS","url":"https://community.spiceworks.com/u/DoctorDNS"}},{"@type":"Answer","text":"

Where is Neally-bot?<\/p>\n

Ok, I’ll do it.<\/p>\n

Hello and welcome.<\/p>\n

If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n

PLEASE READ BEFORE POSTING! Read if you're new to the PowerShell forum!<\/a> .<\/p>\n

\"911201b0-a8de-4760-8558-49c4c9290db8-powershell.png\"<\/p>\n

@alexw<\/a><\/p>","upvoteCount":0,"datePublished":"2021-08-09T23:32:35.000Z","url":"https://community.spiceworks.com/t/showing-error-on-following-powershell-script/807867/5","author":{"@type":"Person","name":"dastafford","url":"https://community.spiceworks.com/u/dastafford"}},{"@type":"Answer","text":"

\n
\n
<\/div>\n\"\" Curly D:<\/div>\n
\n

The module with that command is not available in 32 bit Powershell. Are you using 32 bit?<\/p>\n

Microsoft.PowerShell.LocalAccounts Module - PowerShell | Microsoft Learn<\/a><\/p>\n<\/blockquote>\n<\/aside>\n

I never knew that! I don’t think I’ve ever run the x86 version of Powershell either but thanks!<\/p>","upvoteCount":0,"datePublished":"2021-08-10T00:56:15.000Z","url":"https://community.spiceworks.com/t/showing-error-on-following-powershell-script/807867/6","author":{"@type":"Person","name":"dastafford","url":"https://community.spiceworks.com/u/dastafford"}}]}}