Right, I'm putting a script together to be run post-Windows install to change a few settings, re-name the computer and join a domain. I've got everything working fine but where it currently asks the user to provide a computername (which they will be taking from a spreadsheet) I'd ideally like the script to take the next available name from the file and then write back a value for the adjacent field with a value provided by the user (the end-user's name).
Is this at all possible or am I expecting too much here?
Thanks in advance!
Check out the PowerShell Module https://www.powershellgallery.com/packages/ImportExcel/5.1.1
Related
hoping for some help. I've got a dialog box that I want to do a certain action and running into issues getting the user input as a variable in the script. Essentially I want the user to be able to copy down a row in excel (so, for example, copy 4 numbers down a line in row E). I want the user to be able to paste it into the powershell GUI I made, once pasted I want the button to use that user input and put it in to a script I have already made and execute using each of those numbers as a variable and to return the output of the script. I've got the script and button made i'm just not sure what cmdlet or functions I need to do in order to take the user input and place in the script as a variable. Any help is appreciated, thank you!!
I went through Microsoft Docs and tried to find a cmdlet but either I didn't understand it or it didn't seem to work.
I want to build a simple script that may be useful for others as well, but I have only very basic programming knowledge and can't do it myself without learning how to write powershell scripts from scratch.
What this script is supposed to do is, open an INI file (really just a txt), look for a variable with an assigned value and replace that value from a txt hosted on GitHub, save and then run a program.
This is for the tracker list of qBittorrent, since that feature still hasn't been implemented and the only other script that I could find that does this is for linux and mac, there seem to be none for windows.
The basic idea is this:
get-content "c:\users\[user]\appdata\roaming\qbittorrent\qbittorrent.ini"
# This is where pseudo code starts
get file from "[github-link.txt]"
save file to cache # keeping it is useless as it gets updated daily
find variable "Session\AdditionalTrackers=" in qbittorrent.ini
replace value of variable with content of cached file # this is what I struggle with most when looking for example code. Everything I could find specified the exact string that needed replacing, which in this case is quite long and may change with every update of the file.
overwrite original file
launch program qbittorrent.exe
end script
Conveniently or most likely deliberately all (most) of the tracker lists on GitHub are already formatted in a way that they can be directly pasted into the file without having to worry about formatting. Example.
I can totally understand if nobody wants to do the work, but I would greatly appreciate it and possibly others that are looking for a stopgap for the lacking feature.
If this already exists, go ahead and call me an idiot and while you're at it drop a link ;)
I just found a little tool called Power Automate and it pretty much does what I was looking for. It's not quite as elegant as a single click script but it does the job. Sadly I can't share the "flow" I built because, well, there is no option for it - thanks Microsoft. So, I'll try my best to write it out.
Not quite a "solution" but pretty to close to it.
Here is the "flow":
get file from web // from github for example
read text from file // read downloaded .txt file
read text from file // read qBittorrent.ini
crop text // crop between flags in qBittorrent.ini use "Session\AdditionalTrackers=" as start and "Session\GlobalMaxRatio=" as end and save to cropVar2
crop text // crop before flag use "Session\AdditionalTrackers=" as flag and save to cropVar1
crop text // crop after flag use cropVar2 as flag and save to cropVar3
replace text // replace cropVar2 with content of downloaded file and save to cropVar2
write text to file // write cropVar1,cropVar2,cropVar3
end flow
Keep in mind that any changes to the qBittorrent.ini may change the order of the entries. Which means you have to check if it's still correct after every update and after every change you make in the options. This is a massive cludge after all...
You can input fail saves so that you won't break anything if the order changed.
I can't figure out how the OS knows what files to start first... Like how does it know to run the script which lets you login, instead of another random file. How is the file executed on bootup specified?
It's a program. It can contain names of other program(s) to execute when needed and in whatever order desired. It can also take that information from a file. I see no conceptual problem here.
I want to export some data from Filemaker. Is there a posibility to start a script with an export dialog were the user defines the export location and store this path in a variable so that the user does not have to define the location for following export scripts?
Thanks for your help!
Dan
If you're willing to use a FileMaker plugin, the free BaseElements plugin has a function called BE_SelectFolder(prompt) which opens an open/save dialog, allows the user to select a folder, and returns the location of the folder as a string. So you'd define two variables
Set Variable [$thePath; value: “BE_SelectFolder("Please choose a folder:")”]
Set Variable [$theRef; value: “"filemac:" & $thePath & "/exportfile.fmp12"”]
(that's for Mac, you'd need to adjust the second variable calc for Windows) and then use $theRef as the file reference to save the exports to.
BaseElements is available from http://www.goya.com.au/baseelements/plugin. It's got a lot of other useful functions besides, it's worth checking out.
There is no FileMaker built-in functionality to return the file path for the exported file.
If the user runs the same export twice in a row, the folder selection dialogue will open at the same location. I suspect this is not what you need.
The easiest way to work around the problem is to use AppleScript on a Mac or VBScript on PC to popup a folder select dialogue, return it back to FileMaker and store in a variable. The rest is down to your workflow.
New in FileMaker 14, from May 2015, in the "Miscellaneus script Step" you may find "Get Directory" which is the right one for your question.
His purpose is described as "Sets a variable to the fully qualified path of a specified folder."
You may also create a new folder, in case of needs, if "Allow Folder Creation" parameter is set.
Note: it is not compatible with FileMaker Go while, instead, you may use it for a RunTime distribution.
I'm in the planning stages of a script/app that I'm going to need to write soon. In short, I'm going to have a configuration file that stores multiple key value pairs for a system configuration. Various applications will talk to this file including python/shell/rc scripts.
One example case would be that when the system boots, it pulls the static IP to assign to itself from that file. This means it would be nice to quickly grab a key/value from this file in a shell/rc script (ifconfig `evalconffile main_interface` `evalconffile primary_ip` up), where evalconffile is the script that fetches the value when provided with a key.
I'm looking for suggestions on the best way to approach this. I've tossed around the idea of using a plain text file and perl to retrieve the value. I've also tossed around the idea of using YAML for the configuration file since there may end up being a use case where we need multiple values for a key and general expansion. I know YAML would make it accessible from python and perl, but I'm not sure what the best way to access it from a quickly access it from a shell/rc script would be.
Am I headed in the right direction?
One approach would be to simply do the YAML as you wanted, and then when a shell/RC wants a key/value pair, they would call a small Perl script (the evalconffile in your example) that would parse YAML on the shell script's behalf and print out the value(s)
SQLite will give you greatest flexibility, since you don't seem to know the scope of what will be stored in there. It appears there's support for it in all scripting languages you mentioned.