VMware Cloud Community
Techstarts
Expert
Expert
Jump to solution

How to load function in Powershell

Hi All,

I have downloaded script located Automatically Securing Virtual Machines Using a vCenter Alarm (Scripts.zip)

I want to understand is there a way to automatically load the function defined the script.

every time i want to run this script, i have to load the function.

Thanks for your assistance in advance,

Preetam

With Great Regards,
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

There are a couple of ways to load such a function.

The easiest one is to place the function in one of the profile files, that way it is "known" when you start the PowerCLI session.


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

There are a couple of ways to load such a function.

The easiest one is to place the function in one of the profile files, that way it is "known" when you start the PowerCLI session.


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

Reply
0 Kudos
Techstarts
Expert
Expert
Jump to solution

Thanks Luc.

One more doubt, I want to ensure all VMware admins get Set-VMAdvancedConfiguration cmdlet to run, is it good idea to load $profile.AllUsersAllHosts with the functions. I'm also planning to include customized functions defined over here Working with VM Devices in PowerCLI | VMware PowerCLI Blog - VMware Blogs

With Great Regards,
LucD
Leadership
Leadership
Jump to solution

That would be a good solution, but you still have to devise a mechanism to distribute that profile to all stations.

You could do that with a logon script, by a GPO or whatever procedure you use to distribute files to all the stations.


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