ranski
asked on
Powershell required to backup Environmental Variable
Hi all,
I'm looking for a way to backup a specific variable with the value on machines and then place a temporary one in it's place for a number of weeks for a trial licence. Once this trial is complete I then need to restore that variable to how it was before.
Can anyone help?
thanks
I'm looking for a way to backup a specific variable with the value on machines and then place a temporary one in it's place for a number of weeks for a trial licence. Once this trial is complete I then need to restore that variable to how it was before.
Can anyone help?
thanks
ASKER
thanks. How would I add settings to the EV?
ASKER
also will the above work if the EV isn't present on a system?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If the env var does not exist, the rename will fail, but the new var set. And when reverting, the "new" var will get deleted, and the old not found to rename back, so nothing will stay left.
What do you mean exactly with "add settings to the EV"? An env var contains a string, nothing else.
What do you mean exactly with "add settings to the EV"? An env var contains a string, nothing else.
oBdA, that is absolutely correct. How embarrassing ...
ASKER
Thanks both.
The EV I need to backup is called LICENSE_FILE and i plan to run this as a logon script. Does the above achieve this?
Once it's backed up a new item with the same name needs to be created with a different list of licence servers in the value.
The EV I need to backup is called LICENSE_FILE and i plan to run this as a logon script. Does the above achieve this?
Once it's backed up a new item with the same name needs to be created with a different list of licence servers in the value.
A login script runs each time the user logs in. How should that work here?
ASKER
We could use a drop file. If present do nothing?
Check in the GUI whether this is a User variable or a System variable.
Or open a PS and check which one of these does not throw an error:
Qlemo,
the script won't backup again when the backup variable exists already.
Or open a PS and check which one of these does not throw an error:
[Environment]::GetEnvironmentVariable('LICENSE_FILE', 'Machine')
[Environment]::GetEnvironmentVariable('LICENSE_FILE', 'User')
If it's a System variable, using a logon script won't work, as the change requires administrative permissions. You'd then need a Startup script to do that.Qlemo,
the script won't backup again when the backup variable exists already.
ASKER
Hi oBdA
The EV is System based and is already being set via Group Policy. There may however be locations that have set this manually which is why i need to go that extra but further than just backup the GPO and make a change then revert back.
It's really important that we capture all machines and force then to use the new licence servers but then allow us to revert back a month later.
Any ideas?
The EV is System based and is already being set via Group Policy. There may however be locations that have set this manually which is why i need to go that extra but further than just backup the GPO and make a change then revert back.
It's really important that we capture all machines and force then to use the new licence servers but then allow us to revert back a month later.
Any ideas?
ASKER
oBdA - hope you noticed this post also. https://www.experts-exchange.com/questions/28980918/Drop-File-via-Powershell.html
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
Reverting:Open in new window
The "time trigger" will need to get implemented somewhere else, e.g. as a scheduled task.