I am writing a powershell script to install add-ins to Excel. The issue is I can not find a way to install a COM add-in to excel via powershell. Do you have any sugegstions. I tried to add it under the registry but just got Module Errors.
Thanks.
For this I believe you need to have Excel installed on the computer. Then you can run the following command:
$Excel = New-Object -ComObject Excel.Application
You might want to just look at the open source dfinkle/ImportExcel module.
Related
I have a PnP Power shell script, but it is raising this error:-
The term Get-PnPAzureADUser is not recognized as the name of a Cmdlet
any advice?
Thanks
I tried to reproduce the same in my environment and got the same error as below:
The error usually occurs, if the Pnp PowerShell module is not being installed in the PowerShell.
To resolve the error, make sure to install the module like below:
Install-Module PnP.Powershell
Get-InstalledModule -Name pnp*
After installing the PnP module, I am able to execute Get-PnPAzureADUser successfully like below:
If still the issue persists, re-install the PnP PowerShell module.
I am going to write a powershell script to automatically publish my python code with pyinstaller.
In order to run this script more flexible, I want to check if this local PC already install pyinstaller.
It's similar the syntax in cmd
where /q choco
if !errorlevel! neq 0
and I hope I can write this logic in powershell, is there any solution ?
You can nearly do the same in PowerShell. Just expand where to where.exe to make sure, it is not used as the Where-Object cmdlet. You can query the exit code with $LASTEXITCODE:
where.exe /q choco
if ($LASTEXITCODE -ne 0) {
# choco is not available
}
We are currently rolling out Windows 10 (1903) devices via Intune, and we have requirements to install Azure PowerShell modules under the System account for the devices to communicate and write data to Azure tables. There is a script running under the system account that will write data to Azure every so often.
None of these modules are loading, even when we manually copy them across to the correct location and try the 'offline' method, and we have noticed the following errors on the clients within Event Viewer:
Cannot convert value "2.0.0-preview" to type "System.Version". Error: "Input string was not in a correct format."
The modules that I am trying to install are:
Install-Module -Name Az -AllowClobber -Force | Out-Null
Install-Module -Name AzureRmStorageTable -RequiredVersion 2.0.1 -Force | Out-Null
Any advice/help would be greatly appreciated.
Referring to Github issue: Can't install PowerShell Az - Cannot convert value "2.0.0-preview" Windows 10
If your PowerShellGet module version is less than 1.6.0, you might encounter this issue. You may update the PowerShellGet module nad have another try.
I want to use scripts to create shortcuts under the Windows operating system (.lnk).
In the Windows environment, I chose PowerShell, wrote the script, successfully created .lnk.
$shell = New-Object -ComObject WScript.Shell
$desktop = [System.Environment]::GetFolderPath('Desktop')
$shortcut = $shell.CreateShortcut("$desktop\clickme.lnk")
$shortcut.TargetPath = "C:\Users\scc\Desktop\linkfolder"
$shortcut.IconLocation = "shell32.dll,004"
$shortcut.Save()
But my online running environment is Linux.
Fortunately, I found that PowerShell in 2016 on a multi-platform transplant, yes, it can support Linux. I found it, downloaded, and installed. Under Linux, in the PowerShell command window I can run some basic commands.
There was a run-time error!
When I run the first line of code:
$shell = New-Object -ComObject WScript.Shell
The error message is:
New-Object : Unable to load DLL 'api-ms-win-core-com-l1-1-0.dll': The specified
module or one of its dependencies could not be found.
(Exception from HRESULT: 0x8007007E)
At line:1 char:10
+ $shell = New-Object -ComObject WScript.Shell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-Object], DllNotFoundException
+ FullyQualifiedErrorId : System.DllNotFoundException,Microsoft.PowerShell.Commands.NewObjectCommand
According to the prompt, it seems that the lack of WScript-related modules. Missing DLL file.
My requirement is to run Java programs under Linux to create shortcuts in Windows format. (Stored in the network disk, the file system for the btrfs, and can provide SMB \ AFP \ NFS \ FTP these file services)
Yes, this demand seems to be strange, if you have a new solution ideas and ideas, please tell me or discuss with me.
I have a bold idea: can I use the SMB protocol to create an .lnk file?
You can use the below to create Windows Shortcuts in Linux:
MSLink
It is having both bash version and C source.
Refer this also:
Produce-lnk-file-on-gnu-linux-to-transfer-to-windows
I have these self extracting zip files that I'm trying to extract on 2008/7 machines remotely. But they are coming in a way of .exe and it require user to double click and choose the extractions location.
On WinZip support site they saying to use the /auto flag so the command will look like that:
C:\deploy\.exe /auto C:\path\\
It starts the process in the task manager but it stuck there foever.
When I'm opening the file in text editor it says: !This program cannot be run in DOS mode.
So maybe anyone of you know how I can automate the extraction of the self extraction file silently. Or maybe there is a way to run them with answer file.
Thanks
I know this is older, but I just found this page trying to do the same thing (for a silent driver install)
What the OP put up above works fine.
For example, my line was:
UPS_319_117.exe /auto .\upstemp\
(This was after having the batch file create the upstemp folder). My guess is either the path was wrong so the self-extracting hit an error in the OP's case, or something along those lines and it just hung up waiting for input that wouldn't happen since it was in auto mode...
You can usually unzip these using a third-party ZIP extraction utility.
I had the same problem. I eventually resolved it with PowerShell. Rename your .exe file to a .zip file. Then run a command like this:
powershell -Command "MD C:\PathWhereFileShouldExtractTo; $shell = New-Object -ComObject shell.application; $zip = $shell.NameSpace('C:\PathToZipFile\YourFile.zip'); foreach ($item in $zip.items()) {; $shell.Namespace('C:\PathWhereFileShouldExtractTo').CopyHere($item); }"
I stole the basic PowerShell commands from this article about how to unzip a file with Powershell: How to unzip a file in Powershell?