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)) Showing error that “remove-localUser” is not recognised as the name of cmdlet… clear ForEach ($item in $hostdetail) #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":"
\nI find this script from spicework<\/p>\n
\n$hostdetail = Import-CSV C:\\Users\\jj\\Desktop\\Test\\hosts.csv<\/p>\n
\n{
\n$hostname = $($item.hostname)
\n$username = $($item.username)
\n$computer = $hostname<\/p>\n
\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":"