Desperate to run on liner DOS commands in powershell

I am down to 3 diffident on liners that work perfectly from the dos prompt but in Powershell I  get the below error.

ADSchemaAnalyzer.exe : The term 'ADSchemaAnalyzer.exe' 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.

The command is

 ADSchemaAnalyzer.exe  /targetLDIF "C:\Domain2LAB\INFO\PRODSchema.ldif" /baseServer $baseserver /outputLDIF "C:\Domain2LAB\INFO\LAB.LDIF"

This is the full section of script

###################################################
# Schema START
###################################################
$env:COMPUTERNAME

$baseserver = "$env:COMPUTERNAME.$DNSHostName"
If (Test-Path "C:\Domain2LAB\INFO\PRODSchema.ldif") { #1

# Find ADSchemaAnalyzer.exe and set location start
(Get-ChildItem -Path c:\windows -Filter ADSchemaAnalyzer.exe -Recurse).Directory |Export-Csv $env:temp\scrappath.csv -NoTypeInformation 
$changepath = (Import-Csv $env:temp\scrappath.csv).FullName[1]
$changepath
Set-Location "$changepath"
# Find ADSchemaAnalyzer.exe and set location end

ADSchemaAnalyzer.exe  /targetLDIF "C:\Domain2LAB\INFO\PRODSchema.ldif" /baseServer $baseserver /outputLDIF "C:\Domain2LAB\INFO\LAB.LDIF"

"Wait 15 seconds"
Start-Sleep 15

ldifde -i -f "C:\Domain2LAB\INFO\Test.ldif" -c dc=x $DistinguishedName


} # 1


###################################################
# Schema END
###################################################

Please tell me there is a way to run a a one liner like the one above?

Thanks

March 25th, 2015 8:43am

I found it before I asked the question.   Duhhh

It was a syntax error on my part.   I had one too many commas

Thanks

 $command = @'
cmd.exe /C ADSchemaAnalyzer.exe  /targetLDIF "C:\Domain2LAB\INFO\PRODSchema.ldif" /baseServer $baseserver /outputLDIF "C:\Domain2LAB\INFO\LAB.LDIF"
'@

Invoke-Expression -Command:$command

Free Windows Admin Tool Kit Click here and download it now
March 25th, 2015 8:50am

It's not necessary to use invoke-expression. Just run the command.

March 25th, 2015 10:50am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics