Windows Azure PowerShell cmdlet Error - File skipped because it was already present - powershell

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.

Related

Uninstall VSTO plugin using batch file

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

Not able to execute the "Import-module"

I get below error when i try to execute the command "Import-module script.ps1"
any idea why is that shows up? what need to be done to resolve the issue ?
PS C:\File> Import-module script.ps1
Import-module : The specified module 'script.ps1' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
+ Import-module script.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (script.ps1:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
You need to use .\ to execute scripts, commands from current directory. i.e. ipmo .\script.ps1
As a security feature, PowerShell does not run executable (native)
commands, including PowerShell scripts, unless the command is located
in a path that is listed in the Path environment variable $env:path or
unless you specify the path to the script file.
To run a script that is in the current directory, specify the full
path, or type a dot .\ to represent the current directory.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_command_precedence?view=powershell-7

Powershell invoking DTUTIL error

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.

"Could not find a part of the path" creating a service

I tried to create Azure cloud service using:
Create the Cloud Service
New-AzureServiceProject -ServiceName 'service-lift-and-shift' -Verbose
I am using Azure SDK 2.9 and it is giving the following error:
ServiceName: service-lift-and-shift
New-AzureServiceProject : Could not find a part of the path 'C:\Program Files (x86)\Microsoft
SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Profile\Resources\Scaffolding\General\scaffold.xml'.
At line:1 char:1
+ New-AzureServiceProject
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureServiceProject], DirectoryNotFoundException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.CloudService.Development.Scaffolding.NewAzureServiceProjectCommand
I solved this problem by copying folder
C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Resources
to
C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager\AzureRM.Profile
Since you want create a Could Service which only exists in ASM mode, you should logged in with command: Add-AzureAccount.
I logged in with Add-AzureRmAccount in the first time and I got the same error as you. But when I logged in with Add-AzureAccount in ASM mode, it works.
So make sure you were logged in ASM mode.

Windows sharepoint services (WSS 3.0) stsadm not working

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