How to enable edge extension using powershell script - powershell

Post installation of an application it creates a edge extension but by default it is turned off.
Does anyone have solution to enable it using powershell script?
I'm new to powershell to not sure how to and where to start with.

First, test without Powershell.
Add the ID under HKCU\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallForcelist
Check via edge://extensions
Only manage extensions via either HKCU or HKLM.
More information on Information about extensions.
When this works, you can write the PowerShell code to modify the registry accordingly.
With kind regards,
TheStingPilot

Related

Powershell script to show file extensions in File Explorer

I'm fairly new to the world of Powershell and currently I'm trying to push a Powershell script via Intune to the company devices (all Windows 10 21H2 machines) that will show the file extensions in File Explorer.
So far, I've found this:
Set-Itemproperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -value 0
The PS script is pushed via Intune to a test device and the monitor tells me the policy is applied successfuly but the file extensions are still not visible.
Is there something wrong with the line of code?
My original comment which helped:
The script works fine. I am positive that it is not applied successfully, despite Intune telling you it did. While it is not part of that question, I suppose you should check the user context in which the script is applied and if the eventvwr or any other possible source tells you why the script did not apply correctly. Also, after trying the script locally for myself, you need to refresh the explorer tab via f5 for the change to apply.
Solution was to set it as system/device rights, since it was indeed run as user context, hence solving the problem.
This was the solution:
"The script works fine. I am positive that it is not applied successfully, despite Intune telling you it did. While it is not part of that question, I suppose you should check the user context in which the script is applied and if the eventvwr or any other possible source tells you why the script did not apply correctly. Also, after trying the script locally for myself, you need to refresh the explorer tab via f5 for the change to apply" –
Bowshock

Using PowerShell as VIM shell

I'm using the console version of VIM (not gvim) in Windows, and I have a question about using PowerShell as the shell.
I have set my shell to be powershell and I can run commands, but there's one thing I don't know. I have a bunch of things going on in my PowerShell profile, and I was wondering if it's possible to somehow pass something to PowerShell using VIM, so that in the profile I can check and decide what to do.
I know there's an option -NoProfile we can pass to powershell.exe, but my problem is that I don't want to ignore my whole profile, because I need some parts, such as aliases etc.
Thanks,

Advanced installer powershell script set property

I am using advanced installer 10.7.1. I am adding the custom action of 'run windows powershell script'. What this script does is to check if the installer is being run on an azure vm or not. if it is, only then does it allow the user to install. The script runs fine on the vm, I've checked it. but now I need to display an error message on the basis of a script's result. which means I have to set some property in the script, on the basis of which I will display the error message.
can anybody tell me how to set advanced installer's property through a powershell script.
This is limitation of Windows Installer, not of Advanced Installer. PowerShell does not have access to the Session object of the installation, so you cannot set/get properties from a powershell script into an MSI, no matter the tool used to build the MSI.
The only custom actions that can be used to set a property (scheduled as immediate of course), are VBS scripts (inline or attached files) or DLLs written in C++ or C#. In C# is much easier as you have access to a lot of .NET API (but you also have the requirement of the .NET Framework to be on the end user machines).
#ravikanth
It takes only script text and there is no associated action based on the return value. Weird!
This is how Windows Installer works, i.e. the technology against which all MSI packages are built. More specifically, custom actions running into an MSI cannot use the return code to communicate "what ever they want" with the main installation progress. Windows Installer accepts only a strictly defined set of return codes, in the case of PowerShell custom actions in Advanced Installer, the return code is controlled in the background by the installer.
The scenario in which PS scripts are used in installations is that users usually need to them to make certain configurations on the machine, to prepare it for the installation. (like installing/activating Windows components, configuring network credentials, etc...) For very well and powerfully integrated custom code in the installers DLLs should be used as custom actions, as they provide a full cycle of communication (can get and set properties) and also can be debugged nicely into an IDE (by attaching to the installation process).
I don't know how Advanced Installer works but you can always return a value from the script and then use that value in the caller. For example,
#Custom Script action
#Get the VM details
If (AzureVM) {
$true
} else {
$false
}
Once you have the result from the script, use that to switch the path of installation or display messages.
For Future Reference:
Setting a property value from a script (for immediate custom actions)
To set a property simply include a line with the following syntax in your script:
AI_SetMsiProperty YOUR_PROP <VALUE>
Where YOUR_PROP is the property and <VALUE> is the value assigned to it.
NOTE: This only works with script that are set to run immediately.

run powershell script from anywhere

I am currently working on a powershell script. The objective of this script is to import data from a .csv file from which new users are created if that username does not already exist in the Active Directory.
My question is how can I make this script run from any location so all I have to do is type the name of the script and it will run. I have been able to do this in BASH but can't figure out how to do this in power shell. So far google has been little help.
If it makes any difference i'm using Windows Server 2008 R2
The basic idea is to create Powershell Function which will do the work (or will call other script placed in other location) and put this method to Profile.ps1 script (the script which is loaded everytime you start powershell) - Look at Windows PowerShell Profiles for further details.
The link above for Powershell Function from Tomas Panik is not there anymore so I want to add to the answer here.
Short version:
You can create your function by using Powershell Function. However, this will only last for that session only.
In order for you to use your function regularly, you need to generate/add your function to your own PowerShell profile. Quick tutorials are here and here. Tomas Panik's link to Windows PowerShell Profiles also has very good info.
Update: thanks Hussein Al-Mosawi for reporting the old broken link!

Setting a Environment Variables via Powershell for another User

I am trying to set the environment variables of a user XYZ from the powershell of admin user ABC. I am using Start-Process to launch the powershell of user XYZ but i am not able to capture the output. All this process needs to be done in Java.
Can someone help me out.
Thanks
Ajax
When you change environment variables, the change affects only the current PowerShell session (like if you were using SET command in a Windows cmd). To make the changes permanent, you have to change them with a utility like SETX. You must also have permission to change the values.
Check this TechNet article on it: https://technet.microsoft.com/en-us/library/ff730964.aspx
Basically, you're going to want to set it using the .NET method at the machine scope:
[Environment]::SetEnvironmentVariable("TestVariable","Test Value","Machine")
You'll need to restart your Powershell session to be able to access the new environment variable after creating it.