-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-1Password.ps1
More file actions
33 lines (31 loc) · 1.07 KB
/
Get-1Password.ps1
File metadata and controls
33 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Function Get-1Password {
Param (
[Parameter(Mandatory=$false,
ValueFromPipeline=$false,
Position=0,
HelpMessage="Name of 1Password Vault.")]
[alias("VaultName")]
[ValidateNotNullOrEmpty()] # Specifies that the parameter value cannot be $null and cannot be an empty string "".
[string]$Vault="Employee",
# Don't forget a comma between parameters.
[Parameter(Mandatory=$true,
ValueFromPipeline=$false,
Position=1,
HelpMessage="Name of 1Password Secret.")]
[alias("SecretName")]
[ValidateNotNullOrEmpty()]
[string]$Secret,
# Don't forget a comma between parameters.
[Parameter(Mandatory=$false,
ValueFromPipeline=$false,
Position=2,
HelpMessage="Value of 1Password Secret.")]
[alias("ValueName")]
[ValidateNotNullOrEmpty()]
[string]$Value="Password"
)
$opcli = "C:\ProgramData\chocolatey\bin\op.exe"
$URI = "op://$Vault/$Secret/$Value"
$Result = & $opcli read $URI
Return $Result
}