0

I want to install dfs replication group using powershell commands but the problem is when I login as administrator I cannot create replication group as it through error that system is not in domain. when I login via domain user and password , command runs perfectly. So my requirement is once I login as administrator I can switch to domain user via powershell and run below command:

New-DfsReplicationGroup -GroupName "RG01" 

Thanks

gary
  • 157
  • 1
  • 3
  • 15
  • 1
    If you can run the command as a domain user, why can't you simply run the command as a domain user? – Ansgar Wiechers Sep 20 '17 at 20:26
  • As per my requirement I cannot use domain user directly ..It was just to check I asked permission from respective team. – gary Sep 20 '17 at 20:48
  • This is hacky but you could `Invoke-Command` with the credentials of the domain user. – Jacob Colvin Sep 20 '17 at 20:57
  • Basically its like doing ssh but in powershell. – gary Sep 20 '17 at 20:59
  • I wouldn't say that. Plus while you can use it remotely, that's not a requirement. – Jacob Colvin Sep 20 '17 at 21:02
  • Thanks Jacob !!! I tried invoke but not working ..I can also ping to domain..PS C:\Users\Administrator> Invoke-Command user@example.com Invoke-Command : Parameter set cannot be resolved using the specified named parameters.At line:1 char:1 + Invoke-Command user@example.com + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeComm – gary Sep 20 '17 at 21:02
  • What exactly did you try? – Jacob Colvin Sep 20 '17 at 21:03
  • or if I cannot login can I run commands using domain user ? like user@example:New-DfsReplicationGroup -GroupName "RG01" – gary Sep 20 '17 at 21:07
  • You're not using the correct syntax, try using `Get-Help Invoke-Command` or looking at ms docs. You seem to be thinking of it like SSH, which it is not. You cannot "attach" to anything using this, and explore the filesystem, or anything akin to that. You need to pass it a script block, in the least. You will likely need to create a powershell session with a credential object, and pass that in as well. – Jacob Colvin Sep 20 '17 at 21:12
  • You could try this too. https://stackoverflow.com/questions/28989750/running-powershell-as-another-user-and-launching-a-script – Jacob Colvin Sep 20 '17 at 21:20
  • It prompts for password but fails PS C:\Users\Administrator> Invoke-Command -ComputerName WIN-1U.example.com -Credential example.com\User -ScriptBlock {New-DfsReplicationGroup -GroupName "RG01"} Could not create the replication group named "RG01". An operation error occurred. + CategoryInfo : NotSpecified: (System.String[]:String[]) [New-DfsReplicationGroup], DfsrException + FullyQualifiedErrorId : New-DfsReplicationGroup.TerminatingOMException,Microsoft.DistributedFileSystemReplicatio n.Commands.NewDfsReplicationGroupCommand + PSComputerName : WIN-1U.example.com – gary Sep 20 '17 at 21:25
  • Thanks Jacob !!! I look into the provided link... – gary Sep 20 '17 at 21:26

0 Answers0