2

We were trying to set passphrase in sharepoint via powershell cmdlet.

When we mentioned the switch -confirm in the following line, it asked for confirmation

Set-SPPassPhrase -PassPhrase $passphrase

Then we removed -confirm switch as we passed password in the script itself [though it is security risk , for test environment they needed it] but still it is asking for confirmation. Whether confirmation is by default?

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$passphrase = ConvertTo-SecureString "MyPass#$#@" -asPlainText –Force 

Set-SPPassPhrase -PassPhrase $passphrase

How to bypass confirmation?

Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230

2 Answers2

0

Try this (can't test it...)

Set-SPPassPhrase -PassPhrase $passphrase -confirm:$false
CB.
  • 58,865
  • 9
  • 159
  • 159
0

Cmdlet developers can declare what the impact of their cmdlet is, Low, Medium, or High. In your session, there is an automatic variable $ConfirmPreference, which sets the level at which you will be automatically prompted for confirmation, even if you don't pass -Confirm

Most cmdlets offer a -Force switch which will skip all confirmation, but it doesn't seem like Set-SPPassPhrase has one. You can try explicitly setting -Confirm:$false

You can also try setting $ConfirmPreference = 'None'

See http://blogs.msdn.com/b/powershell/archive/2006/12/15/confirmpreference.aspx and http://msdn.microsoft.com/en-us/library/windows/desktop/bb204629(v=vs.85).aspx

latkin
  • 16,402
  • 1
  • 47
  • 62