Creating New Shares

You can use WMI to help create new file shares. This is the line you need:

md c:\testfolder
([wmiclass]'Win32_Share').Create('C:\testfolder', `
'myShare', 0, 5, 'A new share').ReturnValue

This will create a share for c:\testfolder called myShare and allow 5 connections. Note that you may need admin privileges for this or else the return value of 2 will indicate "access denied" while a return code of 0 will indicate success.


Posted May 11 2009, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.