Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Powershell hashtables as argument to custom cmdlet in C#
- import-module .MyClassLib.dll
- $task = New-Object MyClassLib.OracleScript -Property @{
- Files="MyScript.sql"
- Database="TEST"
- User="USER"
- Password="PASSWORD"
- }
- $result = $task.Execute()
- Invoke-OracleScript @{
- Files="Script.sql"
- Database="db"
- User="user"
- Password="password"
- }
- Invoke-OracleScript @{
- Files="Script.sql";
- Database="db";
- User="user";
- Password="password";
- }
- Invoke-OracleScript -Property @{
- Files="Script.sql"
- Database="db"
- User="user"
- Password="password"
- }
- [Cmdlet(VerbsLifecycle.Invoke, "OracleScript", ConfirmImpact = ConfirmImpact.High, SupportsShouldProcess = true, SupportsTransactions = false)]
- public class Invoke_OracleScript : Cmdlet, IOracleScript
- {
- [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
- public string Files { get; set; }
- [Parameter(Mandatory = true, Position = 1, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
- public string Database { get; set; }
- ....
- get-process -Name notepad `
- -Computername localhost `
- -Verbose
- $process = new-object psobject
- $process | add-member -name name -value notepad -type noteproperty
- $process | add-member -name computername -value localhost -type noteproperty
- $process | get-process
- $process = new-object psobject -property @{ name="notepad";
- computername = "localhost";}
- $process | get-process
- Function Add-ThreeNumbers {
- param ($a,$b,$c)
- $a + $b + $c
- }
- $params = @{a=10; b=15; c = 20}
- Add-ThreeNumbers @params
Advertisement
Add Comment
Please, Sign In to add comment