Has anyone tried Powershell?

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Developers, Moderators

Post Reply
speedbird
Posts: 9
Joined: Tue Dec 22, 2009 7:56 pm

Has anyone tried Powershell?

Post by speedbird »

I'm running spine and custom WMI VB scripts for a few polls (on a Windows server box, with IIS). Out of curiosity, has anyone tried using Powershell for custom scripts? If so, how'd it work, or did it?

My hunch is the main time waster would be waiting for PS to actually invoke - i've heard it said that any shell that takes more than 5 seconds to load isn't really a shell... i may have to agree.

Cheers.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Funny you should bring this up...I was just reading an article about the improvements to powershell 2.0 and was thinking it would make a good replacement for WMI scripts (and lots of other things!). I haven't given it a try yet though, nor do recall anyone publishing powershell scripts. In theory, it really shouldn't be any different from other scripts to get working with Cacti.
speedbird
Posts: 9
Joined: Tue Dec 22, 2009 7:56 pm

Post by speedbird »

I've been doing a fair amount of work outside of Cacti w/ powershell. The biggest hassle I see is figuring out how to a) call powershell from within cacti, since PS is designed to not allow code to run without command line execution - i.e., you can't go start->run->mypowershellscript.ps1 . You have to be w/in the powershell cli, then run the script. and b) how to stop it from taking 5 to 10 seconds to load.

But the thought is intriguing, especially since it would allow much better interaction with WMI.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

speedbird wrote: a) call powershell from within cacti, since PS is designed to not allow code to run without command line execution - i.e., you can't go start->run->mypowershellscript.ps1 .
You apparently can though by changing some settings. More details: http://technet.microsoft.com/en-us/libr ... 76949.aspx
speedbird wrote: b) how to stop it from taking 5 to 10 seconds to load.
Read through Speeding Up PowerShell Startup and the other linked posts with the ngen scripts?

Otherwise, an ideal dream is that Cacti will one day support script servers for customizable languages i.e. perl script server, powershell script server, etc. That way the main executable stays open during the polling cycle and gets fed scripts instead of a new instance launched for every script.
weirk
Posts: 11
Joined: Wed Mar 30, 2011 2:38 pm

Re: Has anyone tried Powershell?

Post by weirk »

The real problem is being able to use it from a linux box. LOL.
Well at least for me it is, I have a lot of devices and windows boxes just can't handle it, I've been able to get the wmi queries to work from linux, barely.
I am a big powershell user, between vmware, sql, exchange, desktop management. It's great, and you can use the powershell get-wmi to gather wmi objects as well as dig through them, and get values. You can also have it do things multithreaded, etc... But getting those results back to a linux box might be a pain (not impossible) Powershell is heavily into the .NET, so I have a hard time seeing there being a port to linux.
But for the windows cacti machines, it could be handy.
mrossFTEK
Posts: 22
Joined: Wed Jul 26, 2023 8:13 am

Re: Has anyone tried Powershell?

Post by mrossFTEK »

reviving an old topic, but you can do powershell on linux
https://learn.microsoft.com/en-us/power ... rshell-7.3
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: Has anyone tried Powershell?

Post by Osiris »

Well, that's cute. MS made PowerShell OSS. So, this makes sense.
Before history, there was a paradise, now dust.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Has anyone tried Powershell?

Post by TheWitness »

A script server for powershell might be interesting. I'm not sure how it would work or course.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Has anyone tried Powershell?

Post by netniV »

PowerShell can be run directly and passed a script plus parameters to run. There may be startup issues if many modules are set to auto-load when PowerShell starts, but a bare PowerShell should not take long at all.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Has anyone tried Powershell?

Post by TheWitness »

I read that as Script Server for Powershell may not be required.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests