-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package main | ||
|
||
// "bitbucket.org/creachadair/shell" | ||
import ( | ||
"flag" | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
powershell "github.com/KnicKnic/go-powershell" | ||
) | ||
|
||
func main() { | ||
// create a runspace (where you run your powershell statements in) | ||
runspace := powershell.CreateRunspaceSimple() | ||
// auto cleanup your runspace | ||
defer runspace.Delete() | ||
|
||
// execute a statement in powershell consisting of "emit this string" | ||
// this will output that object into the results | ||
results := runspace.ExecStr( `"emit this string"`, true) | ||
// auto cleanup all results returned | ||
defer results.Close() | ||
|
||
// print the string result of the first object | ||
fmt.Println(results.Objects[0].ToString()) | ||
// Output: emit this string | ||
} |