robertarenson
asked on
How to Disable a File Share on a server via a text file
I need to disable multiple file shares from users who are no longer in our organization. I have added all of the share names to a text file but need to set the text file so that the PowerShell Script can call it so that it can then remove all of the shares from the text file from the 1 share server name.
Not sure if I need the $ included in the usernames though since the actual share is restricted to usera$
Thank you
Example of what is in the text file:
usera
userb
userc
PS C:\> Remove-SmbShare -Name Files -CimSession SRV2K12RC
Confirm
Are you sure you want to perform this action?
SRV2K12RC: Performing operation 'Remove-Share' on Target
'*,Files'.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?]
Help (default is "Y"):
Not sure if I need the $ included in the usernames though since the actual share is restricted to usera$
Thank you
Example of what is in the text file:
usera
userb
userc
PS C:\> Remove-SmbShare -Name Files -CimSession SRV2K12RC
Confirm
Are you sure you want to perform this action?
SRV2K12RC: Performing operation 'Remove-Share' on Target
'*,Files'.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?]
Help (default is "Y"):
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can't run it on W2003. It only works in PS3 on W8/W2012 and later.
ASKER
Darn, the share server is only 2003 R2 server.
Bad luck! You tried on your workstation before, obviously.
ASKER
Unable to get to work
Open in new window
Remove the last switch to apply the change. As-is the removal is only simulated.