/build/static/layout/Breadcrumb_cap_w.png

Custom Inventory to return Random Number

I am looking to have a custom inventory that will return a random number. I am planning on using this to slow down some software deployment/updates (namely Dell Command Update). For example, I will only target devices where the random number is between 1 and 20 to update a random subset of our devices. We have roughly 2500 devices, so in the example 1-20, it should target roughly 20 devices given a random number between 1 and 2500. Every time the device would be inventoried, it would change the random number to cycle in new devices to update.


I believe I have come close, but it does not seem to work as id expect.

ShellCommandNumberReturn(cmd /c powershell -command "Get-Random -Minimum 1 -Maximum 2501")

This does not work, it will just not report anything.


ShellCommandTextReturn(cmd /c powershell -command "Get-Random -Minimum 1 -Maximum 2501")

This works, but then when sorting by Random Number, it is ordered in alphabetical order, not numeric. For example: 1,1000,2,23,2500


ShellCommandNumberReturn(cmd /c echo %random%)

This does not work either.


I'd prefer if it was a number between 1 and 2500, but I'll settle for any random number, stored as a number. 


0 Comments   [ + ] Show comments

Answers (2)

Posted by: czavaskis 9 hours ago
White Belt
1

ShellCommandNumberReturn(cmd /c echo %RANDOM%")


The Windows operating system uses a pseudo-random number generator (PRNG) that is considered the most commonly used PRNG. The pseudo-randomness of the output from this generator is important for the security of almost any application running in Windows. 

The %RANDOM% pseudovariable in cmd.exe generates a "random" number, but it's not very random. Here are some reasons why:

The %RANDOM% pseudovariable generates the same "random" number until the clock ticks over to the next second.

If two copies of a script are running at the same time, they will both get the same "random" number and mix their output together. 

Posted by: ISEKOLD 5 days ago
Orange Senior Belt
-1

Maybe this is working. I think there was an issue with the report I was using to check the number. Maybe something to do with editing the CIF.


ShellCommandNumberReturn(cmd /c powershell -command "Get-Random -Minimum 1 -Maximum 2501")

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ