VMware Cloud Community
Vimal348
Enthusiast
Enthusiast
Jump to solution

vCenter Certificate

Hello,

I am looking for a script that can generate the Certificate expiry date of a vCenter(s).

I got this link: (Get-STSCerts.ps1) https://code.vmware.com/samples?id=7336#comments

But I was able to run the commands in the instruction Point 1 and 2. But getting the below error for point 3. Any suggestion? Or any other script that can use for ?

Get-STSCerts : The term 'Get-STSCerts' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The problem is the quotes you used when you were dot-sourcing the .ps1 file.

That should be (without the quotes)

. .\Get-STSCerts.ps1

With the quotes, you are just showing a string on the console.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

It looks as if you didn't do step 1 or 2 correctly.
Did you notice the 2 dots with a space in between in step 2?

That is called dot-sourcing and that is how you make sure your session "knows" that function.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Vimal348
Enthusiast
Enthusiast
Jump to solution

Hello @LucD 

 

This is what I have run:

cd 'C:\Scripts\vCenter Certificate'
". ./Get-STSCerts.ps1"

Get-STSCerts -vcenters <vCenterName> -user 'xxxx.xxx.com' -password 'xxxxxx'

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can check if you did that correctly by running

Get-Command -Name Get-STSCerts


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Vimal348
Enthusiast
Enthusiast
Jump to solution

Thank you for the reply @LucD 

Not sure what I am doing wrong:

Vimal348_0-1608407793173.png

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The problem is the quotes you used when you were dot-sourcing the .ps1 file.

That should be (without the quotes)

. .\Get-STSCerts.ps1

With the quotes, you are just showing a string on the console.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Vimal348
Enthusiast
Enthusiast
Jump to solution

Hello,

Thank you @LucD ,

I was still getting some other error. But I got it fixed by unblocking it ( ' PS C:\> Unblock-File -Path C:\Downloads\script1.ps1') and then ran as you said. Thank you

Reply
0 Kudos