Remove-Windows Feature throwing error

I have a listing of servers in my environment that I’m trying to disable SMBv1 on. Mixture of both 2008R2 and 2012R2 boxes, trying to automate the process as much as I can.

Here’s my code:

Connect-VIServer -Server v-center.x.x.com $server = Get-VM -Name Test-NewServer Enter-PSSession $server Remove-WindowsFeature -Name FS-SMB1 Exit-PSSession Restart-VMGuest $server 

When I run the code together, I get this error:

Remove-WindowsFeature : The target of the specified cmdlet cannot be a windows client-based operating system. At line :4 char:1 + Remove-WindowsFeature -Name FS-SMB1 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Category Info : DeviceError: (localhost:String) [Uninstall-WindowsFeature], Exception + FullyQualifiedErrorId : WindowsClient_NotSupported,Microsoft.Windows.ServerManager.Commands.RemoveWindowsFeatureCommand WARNING: GuestId property is deprecated. Please use ConfiguredGuestId and RuntimeGuestId properties instead. 

However, when I run the code one line at a time, it executes successfully with no errors. I’m assuming that the code needs some pauses in the process to make it run smoothly. Also, I’d love to schedule the reboots for 8:00 PM the day that I run the code so that everything is happening in off-hours. What’s my most efficient method of achieving this goal? Thank you in advance.

submitted by /u/Moviefreak4702
[link] [comments]

Leave a Reply