I've to uninstall a vsto plugin. I'm using this command in powershell :
"C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe" \Uninstall file:///C:/Users/username/source/repos/OutlookAddIn3/OutlookAddIn3/publish/OutlookAddIn3.vsto
This statement I copied from UninstallString in registry of this Add-in. But this gives following error in powershell :
At line:1 char:78
+ ... iles\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe" \Uninstall "file:/ ...
+ ~~~~~~~~~~
Unexpected token '\Uninstall' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
Can someone tell the correct way of using this command?
Edit 1:
The cause of error was using \uninstall instead of /uninstall and as per the suggestion given by #Abraham Zinala, I added & before the command to make it run in PowerShell.
& "C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe" /uninstall file:///C:/Users/username/source/repos/OutlookAddIn3/OutlookAddIn3/publish/OutlookAddIn3.vsto /silent
To make it work in using Batch file, just have to remove & previous command. The working command in batch file is :
"C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe" /uninstall file:///C:/Users/username/source/repos/OutlookAddIn3/OutlookAddIn3/publish/OutlookAddIn3.vsto /silent
Related
I'm currently in the process of building a deployment process in octopus deploy and as part of that I want to use DTUTIL to create folders and load SSIS packages to our server.
This text "C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe" /SourceServer [servername] /FC SQL;\;[foldername], with appropriate server and folder names, which works in DOS.
Here is the rub, if I use the same code in Powershell I get an error:
$Command ="`"C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe`" /SourceServer MYSERVER /FC SQL;\;Folder1";
invoke-Expression $Command;
invoke-expression : At line:1 char:73
+ ... Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe" /SourceSe ...
+ ~
You must provide a value expression following the '/' operator.
At line:1 char:73
+ ... \Microsoft SQL Server\130\DTS\Binn\dtutil.exe" /SourceServer MYSERVER ...
+ ~~~~~~~~~~~~
Unexpected token 'SourceServer' in expression or statement.
At line:1 char:1
+ invoke-expression $Command
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
+ FullyQualifiedErrorId : ExpectedValueExpression,Microsoft.PowerShell.Commands.InvokeExpressionCommand
Has anyone got any idea how to remedy this?
Anthony
You can execute the EXE using the & operator:
& "C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtutil.exe" /SourceServer MYSERVER /FC SQL;\;Folder1
Also, the above Invoke-Expression command failed in the same way when I ran it in PowerShell directly, this doesn't appear to be an issue with running the PowerShell within Octopus.
I downloaded the PoshRSJob module. When I try to import the module it always throws the following error (translated from German):
PS C:\WINDOWS\system32> ipmo "C:\Program Files\WindowsPowerShell\Modules\PoshRSJob"
ipmo : The File "C:\Program Files\WindowsPowerShell\Modules\PoshRSJob\Scripts\TabExpansion.ps1" could not be loaded. The File "C:\Program
Files\WindowsPowerShell\Modules\PoshRSJob\Scripts\TabExpansion.ps1" is not signed digitally. You can't execute this script on your system. More information: "about_Execution_Policies" unter
"http://go.microsoft.com/fwlink/?LinkID=135170"..
In Zeile:1 Zeichen:1
+ ipmo "C:\Program Files\WindowsPowerShell\Modules\PoshRSJob"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : Sicherheitsfehler: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
Our ExecutionPolicy is RemoteSigned
Is there a way to get this module working in a RemoteSigned environment, without Bypassing the Executionpolicy everytime I use the Module in a Script, and without setting the ExecutionPolicy to Unrestricted?
It might be that Windows is treating the files as remote files despite being on your machine locally. Sometimes Windows will know when files have come from the internet (for example if you download through IE or Edge instead of say, Firefox). Behind the scenes, this is storing zone information in an alternate data stream associated with the file, but that can be modified or stripped off.
Right click the PSD1, PS1, PSM1 files inside the module and choose "Properties" and if there's an unblock option, make sure it's unticked.
Alternatively you could run the cmdlet Unblock-File if you have PowerShell 5.1 or greater.
I'm currently writing a powershell script that asks for a single set of admin credentials, and uses those to run relevant applications, pulled from a network-hosted CSV. When I try to run
Start-Process $tools[$userInput-1].path.toString() -credential $credential
(where $tools is returning "C:\Program Files\Microsoft\Exchange Server\V14\Bin\Exchange Management Console.msc") I get the error below
Start-Process : This command cannot be executed because the input "C:\Program Files\Microsoft\Exchange Server\V14\Bin\Exchange Management Console.msc" is an Invalid Application. Give a valid application and Run your command again.
At line:1 char:14
+ Start-Process <<<< "C:\Program Files\Microsoft\Exchange Server\V14\Bin\Exchange Management Console.msc" -credential
Get-Credential
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
If I need to, I'll just write a .bat file and run that, but I'd rather avoid that whenever possible.
And the reason I'm not using Invoke-Item is because it can't take -Credential, even if the man file says otherwise.
.msc is a saved console file, the host of which is mmc, so to start this from powershell you could use syntax similar to the following:
$mmcPath = "C:\Windows\System32\mmc.exe"
$mscPath = "C:\Program Files\Microsoft\Exchange Server\V14\Bin\Exchange Management Console.msc"
Start-Process -FilePath $mmcPath -ArgumentList $mscPath
Running the following Windows Azure PowerShell cmdlet for Windows Azure: Import-Module 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1' generates the error below. I ran PowerShell with elevated priveleges and Get-ExecutionPolicy returns RemoteSigned.
Here is the error:
Import-Module : The following error occurred while loading the extended type data file:
Microsoft.PowerShell, C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Microsoft.WindowsAzure.Manag
ement.Websites.Types.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Microsoft.WindowsAzure.Manag
ement.SqlDatabase.Types.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
At line:1 char:14
+ Import-Module <<<< 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1'
+ CategoryInfo : InvalidOperation: (:) [Import-Module], RuntimeException
+ FullyQualifiedErrorId : FormatXmlUpateException,Microsoft.PowerShell.Commands.ImportModuleCommand
The script does not complete after this error.
After half a day of being stuck on this, I just decided to continue with the steps, and it worked flawlessly. So I guess it was simply a warning, but did not effect the rest of the process. I have not had any issues as a result.
I am new to powershell. I am trying to backup a sharepoint site using a stsadm command but for some reason I keeps on giving me some error.
Here is what I am doing:
PS C:\Users\Administrator> Stsadm –o backup –url >http://server< name:port -filename path\filename to be used for the backup file
Here is the error I am getting:
The term 'stsadm' is not recognized as the name of the cmdlet, function, script file, or operable program. Check the spelling of the name, or path was included, verify that the path is correct and try again,
At line:1 char:7
+ stsadm <<<< stsadm –o backup –url >http://server< name:port -filename path\filename to be used for the backup file
+CategoryInfo : ObjectNotFound: [], CommandNotFoundException
+FullyQualifiedErrorID : CommandNotFoundException
Stsadm is not a powershell script, it is an executable located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12 or 14 'hive'.
Normally you would refrain from calling stsadm when running powershell as it is effectively deprecated in SharePoint 2010.
You can however change directory to locate the executable and call it if you wish.
Here is a list of stsadm equivalents in powershell.
check this blog post => Backup and Restore SharePoint 2010 Site Collection with PowerShell: http://www.bradleyschacht.com/backup-and-restore-sharepoint-2010-site-collection-with-powershell/
Perhaps, it is what you are looking for