Link to home
Start Free TrialLog in
Avatar of tiras gans
tiras gansFlag for United States of America

asked on

Share off directories on each server

How to do it faster instead of manually share it out.
So on each Windows 2008 Server I need to share out two directories.
C:\folder\share1
C:\folder\share2

Is there a way to do it fast with permissions?
ASKER CERTIFIED SOLUTION
Avatar of becraig
becraig
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tiras gans

ASKER

Nice!  Does it set the default permissions?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Trying to work with your win32 script. No luck as of yet..
Are you facing a specific error ?

Can you please post that is you are
not yet. Just compiled the script and running .  but nothing happens yet.  No shares are being created.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
its just all these commands are not recognized...  Maybe need to edit environment users or systems variables..

'$servers' is not recognized as an internal or external command,
operable program or batch file.

'foreach' is not recognized as an internal or external command,
operable program or batch file.

'{' is not recognized as an internal or external command,
operable program or batch file.

'$Foldername' is not recognized as an internal or external command,
operable program or batch file.

'$Sharename1' is not recognized as an internal or external command,
operable program or batch file.

'$Foldername2' is not recognized as an internal or external command,
operable program or batch file.

'$Sharename2' is not recognized as an internal or external command,
operable program or batch file.
$Foldername)) was unexpected at this time.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Straight from the powershell and still not recognized.

PS C:\path> powershell
The term 'powershell' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:11
+ powershell <<<<
    + CategoryInfo          : ObjectNotFound: (powershell:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for the delay.  Still struggling with this.  error shows

PS C:\path> .\newshare.ps1
 already share exists on servername
sharename already share exists on servername
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Now cant even connect.

PS C:\path> .\newshare.ps1
[servername] Connecting to remote server failed with the following error message : WinRM cannot process the request. Th
e following error occured while using Kerberos authentication: The network path was not found.
 Possible causes are:
  -The user name or password specified are invalid.
  -Kerberos is used when no authentication method and no user name are specified.
  -Kerberos accepts domain user names, but not local user names.
  -The Service Principal Name (SPN) for the remote computer name and port does not exist.
  -The client and remote computers are in different domains and there is no trust between the two domains.
 After checking for the above issues, try the following:
  -Check the Event Viewer for events related to authentication.
  -Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or us
e HTTPS transport.
 Note that computers in the TrustedHosts list might not be authenticated.
   -For more information about WinRM configuration, run the following command: winrm help config. For more information,
 see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException
    + FullyQualifiedErrorId : PSSessionStateBroken
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
PS C:\path> gc serverlist.txt | % { test-wsman -computername  $_}
Test-WSMan : The client cannot connect to the destination specified in the request. Verify that the service on the dest
ination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running
on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on t
he destination to analyze and configure the WinRM service: "winrm quickconfig".
At line:1 char:35
+ gc serverlist.txt | % { test-wsman <<<<  -computername  $_}
    + CategoryInfo          : InvalidOperation: (serverhostname:String) [Test-WSMan], InvalidOperationException
    + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.TestWSManCommand
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial