Executing a command through through exec.Command()

I am trying to run a command from below code,
which reads a content of a file on remote machine given by IP - ip with credentials username and password,
and redirect its content to output.txt
But when I run my code, command fails, saying, exit status 1.
Astonishingly, when I try to run same command from command prompt it works just fine.

Please let me know if anything is needed from my side

 func functionName(psexecPath,ip,username,password string) {
 	ipFormat := "\\\\" + ip
 	uFlag := "-u"
 	pFlag := "-p"
 	cmdExe := "cmd"
 	cmd := exec.Command(psexecPath, ipFormat, uFlag, username, pFlag, password, cmdExe,  "/C", "type /path/to/somefile.txt", ">", "output.txt")
 	var stdout, stderr bytes.Buffer
 	cmd.Stdout = &stdout
 	cmd.Stderr = &stderr
 	err := cmd.Run()
 	if err != nil {

You can’t use the redirection operator with Cmd.

You either need to wrap the call in a shell interpreter or open a file stream that write to your output file and use it as the cmds stdout.