darrenjrobinson/1Pwd

Problem with spaces in variable for title value (and other property)

Closed this issue · 2 comments

Problem when variable for title have spaces:

$TitleSuffix = "text1 text2 text3 text4"

$items = (Invoke-1PasswordExpression "item list --vault $1PwdVault --tags $tags")
foreach ($item in $items) {
	$TitleSuffix = $($item.title).ToString()
	$Title = "$TitlePrefix $TitleSuffix"
	$ItemID = $($item.id).ToString()
	echo $Title
	Invoke-1PasswordExpression "item edit $ItemID title=$Title"
}

Text1 VCSA

[ERROR] 2023/09/07 22:03:53 cannot add a field with no value VCSA

Hi,

You code snippet is incomplete so I don't know what $TitlePrefix looks like.
But I think that you are expecting to happen can be achieved if you put single quotes around your $Title variable on your edit line.

Invoke-1PasswordExpression "item edit $ItemID title=`'$($Title)`'"
$TitlePrefix = 'oneword'
...
Invoke-1PasswordExpression "item edit $ItemID title=`'$($Title)`'"
...

THX, working.