I have a PS Script that I want to share it with some people. I only want people to be able to execute it, not viewing or modifying it. How would I do that?
Also assuming the people I share the script with know little about PowerShell and how to change execution policy to make it run what would be the best way to do it? I was thinking of making a bat file and set execution policy to unsigned because remotesigned doesn't execute files from the internet right? Would unsigned cause any problem for security since I only execute a single script?
Lastly, I will be storing some password with convertto/from securestring
Would it matter to setup securestring if my file can not be modified in question 1? What happens in the case if I forget my password while using securestring method?
You could download and install PowerGui, and then compile your .ps1 file to be a .exe however they would still be able to pull the contents of the file when they run it as it exports a copy to %temp%, but they would not be able to 'easily' modify the file. I say 'easily' because basically anything with computers can be performed with the will, time, and smarts to know what you're doing, and I don't know how secure this password or anything else needs to be.
Related
I have a script that processes a couple of thousand files and copies the files individual users folders. This process takes some time as it checks for proper security on each folder and if the user associated with the file still has a valid account. Because this takes time, there has been instances where the script was closed inadvertently while it was in the middle of processing.
Has anyone come up with a method to check if the script did not finish completely and if so continue processing where it left off?
I was thinking to add a check for a file at the start of the script and if it doesn't exist create the file. The last part of the script would remove the file. That way if the script was closed without finishing the file would exist on the next run and it would 'know' to continue.
I'm just looking for advice on any method that would be better that this.
I'm developing some scripts that I later pack into EXE using PS2EXE to ship to end user. The key point here is that they only know how to double click executable and they want to do just that. The script then builds simple GUI using WPF where end user can click buttons and check boxes and do whatever they need to do.
Now, as I have several similar scripts and total volume of code grows bigger, I would like to reuse some of it packing various functions into modules and just use Import-Module in my script - standard practice.
However, I realized, that when I use PS2EXE in this case, it does not pack modules in the EXE file. It still works but it requires model to be deployed on the user's machine. Which immediately makes it over-complicated for the end user.
My question - is there a way to develop script re-using code through modules and still pack it into EXE files (along with all the imported modules) for end users, so that the single EXE file is everything they need?
Set command in the EXE file that you want to reuse that return the required function declaration statements.
other scripts that want to use these functions, obtaining these statements by executing the command,and execute them through Invoke-Expression Cmdlet.
Basically what I want to do is locate a shared folder on the server (I'll be running this script from the domain controller), unshare it (so I make sure no user is still using files from there, to avoid issues), and then backup all the files from that folder into a .zip/.rar, then share the folder again. I been looking into how to automate this using powershell (I dont have much experience with it), I found this script (https://github.com/Seidlm/PowerShell-Backup-Script/blob/master/BackupScript.ps1) that im planning to modify, but I still not know how to unshare and share a folder with powershell or how to make it so that the script is automatically executed for example every day at 1:00 am or something like that, how would I be able to this? I dont want you guys to do my homework, if you could just point me in the right direction or link some documentation I would apreciate it.
I am trying to updating a software that is company wide. When the update is applied to the server, the client machines recognize they need an update and ask if you wish to update or not. To update, the user would need to run as admin, which is'nt an option in this case.
We would like to automate this process using powershell, using the Invoke-Command feature. For the most part, the only thing that the update does is copy new files to the programs folder, which we have achieved with robocopy. However, there is one registry key that needs to be added in multiple locations. There is a setup file that does this, but requires a user (with admin privileges) click a couple buttons, and we want this to be completely automated.
So I guess the short version of my question is, what is the best way to handle the registry changes that setup.exe does? It would be nice if there was a way to invoke the script that the executable does.
As for my question, I solved the problem with a slightly diferent approach. (One that should have been tried initially)
When (ProgramName).exe is run, if it sees that it needs updated, it runs a program called (ProgramName).setup.exe with the parameters :
Client="Local folder" server="server location"
These parameters did NOT work from the command line, however, and so I ended up using a powershell script to make a scheduled task that ran (ProgramName).setup.exe with said parameters.
Another huge advantage to this was the fact that I could create an icon that allowed a regular user to run the scheduled task with admin privileges. I couldn't setup a shortcut directly, however, I wrote an AUTO-it Executable that would run the task as admin.
I hope someone can get some level of help out of this post!
I've been searching for this for awhile now, and I am not sure if I am just not using the correct search terms or if the answer is really that hard to find.
What I am trying to do is to create a new Windows service for a game server from a batch file, and then have a task run another batch file every 30 minutes or more that would run two commands on the game server's command line and do some file work.
Specifically, I am running a Minecraft server using Bukkit for a gaming community I help run, and I want to make sure that the thing is always up unless I specifically tell it to stop (like a service). Bukkit is run directly from a batch file and has it's own command line thing running on it.
I am told that you CAN run this type of thing as a service, but the command line will be hidden from view and/or interaction. This is the second part of my query. I have a handy little backup.bat file that copies all the world files and userdata files into a backup directory, 7zips it, and deletes the directory. The only thing is, is that Minecraft likes to always have the worlds' region files open and writing at all times, meaning that it could cause map corruption if I just run it straight off. To compensate, I need to run the command "save-off" on the server to disable the file hooks temporarily, run the backup, and as soon as it finishes, run "save-on" so that the game can continue without lost data.
What I would like to know about this second one is, is it possible to interface with the game service through a batch file, or do I need to create an application to do that? If the latter, how exactly does one go about doing that? I have moderate C++ knowledge (up through my second OO-C++ course in college), and can possibly learn another language if absolutely necessary.
So, in short, two questions:
1. Is it possible to, and how to run a BAT file as a Windows Service?
2. How to interface with said service via BAT files, and if not possible, what kind of application do I need to write (redirection to or writing a tutorial works for me).
Thank you in advance for any and all help!
Old question, user account doesn't seem active on SO anymore, but hey, if you stumble upon this because you have a similar problem:
Since we are speaking about a Bukkit Minecraft server, turn to the "Essentials" plugin for Bukkit.
It now includes a Backup function that does exactly what the OP asks for, namely stop the save so the files can be manipulated without corruption, launch a script, then starts again.
The script can be a backup one (examples provided in the linked page) but can be used to run any operation on the world's files.