I have a Windows 2008 R2 machine, and I have installed the VS2010 and SP1, Windows Azure SDK 1.7 and all other tools of Azure SDK and PowerShell cmdlets from the below links
https://www.windowsazure.com/en-us/manage/downloads/
When I run the Windows Powershell for Windows Azure Cmdlets, it is showing the error:
Add-PSSnapin : The Windows PowerShell snap-in 'WAPPSCmdlets' is not installed o
n this machine.
At line:1 char:21
+ cd c:\; add-pssnapin <<<< WAPPSCmdlets
+ CategoryInfo : InvalidArgument: (WAPPSCmdlets:String) [Add-PSSn
apin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad
dPSSnapinCommand
I have also tried the following link but no use.
http://social.msdn.microsoft.com/Forums/is/windowsazuredevelopment/thread/4c59fc7e-3ead-482e-88c3-f5555e915c84
Could you try loading the module manually?
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1"
And then simply try any CmdLet (like Add-AzureCertificate) to see if you can use it.
Update: Since Add-AzureCertificate works for you this means all cmdlets are now available. To make things easier you can simply create a shortcut on your desktop with the following target:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NoExit
-Command "cd 'C:\'; Get-ChildItem 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure*.psd1' | ForEach-Object
{Import-Module $_}"
Related
I am trying to automate installing a module from a custom repository on a windows machine by pushing a ps1 script from a Linux machine to the windows machine, and then trying to execute the script over ssh. The windows is running a cygwin server. When I run the ps1 script directly on powershell, the script runs fine. But when I run the same over ssh, it fails with the following error:
PackageManagement\Install-Package : Exception calling "CloneRequest" with "3" argument(s): "Object reference not set
to an instance of an object."
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1875 char:34
+ ... $null = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exce
ption
+ FullyQualifiedErrorId : NullReferenceException,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
The script fails at the line:
Find-Module -Name <module name> -AllVersions -Repository <repo name> | Install-Module -SkipPublisherCheck -Scope AllUsers -Force
This is how I am calling the script from the linux machine:
ssh user#windowsIp powershell -NonInteractive -File E:\moduleInstaller.ps1 repositoryUrl moduleName moduleVersion
Trying to script an upgrade for my Dynamics organization following this TechNet blog.
But running into the below error which I understand, but not sure the process to get the PSSnapin onto my system.
PS C:\Program Files\Dynamics SDK\SDK\Bin> Add-PSSnapin Microsoft.Crm.PowerShell
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.Crm.PowerShell' is not installed on this computer.
At line:1 char:1
+ Add-PSSnapin Microsoft.Crm.PowerShell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Crm.PowerShell:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
First of all, sign in with the Administrator account on your Microsoft Dynamics 365 server.
Then in elevated mode Run
Add-PSSnapin Microsoft.Crm.PowerShell
If you have no registered then use the Use PowerShell cmdlets for XRM tooling to connect to Dynamics 365
You can externally also download the same from GITHUB:
Link provided by theMadTechnician
Hope it helps
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 apologize if this is a NOOB question but I wrote a PowerShell script on my windows 10 box and I am trying to run the script on a 2008 box. On the new install of the 2008 box I had to add the windows powershell feature. My end goal is to install the Web Server (IIS) Administration Cmdlets
PS C:\Users\Administrator> Get-Module -ListAvailable | Import-Module
PS C:\Users\Administrator> Get-Module -ListAvailable
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest BitsTransfer {}
Manifest PSDiagnostics {Enable-PSTrace, Enable-WSManTrace, Start-Trace, Disable-PSWSManCombined...
PS C:\Users\Administrator>
PS C:\Users\Administrator> add-pssnapin WebAdministration
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2.
At line:1 char:13
+ add-pssnapin <<<< WebAdministration
+ CategoryInfo : InvalidArgument: (WebAdministration:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
PS C:\Users\Administrator>
PS C:\Users\Administrator> Import-Module WebAdministration
Import-Module : The specified module 'WebAdministration' was not loaded because no valid module file was found in any module directory.
At line:1 char:14
+ Import-Module <<<< WebAdministration
+ CategoryInfo : ResourceUnavailable: (WebAdministration:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId :Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Any ideas?
You need to install the IIS managment tools before the WebAdministration-module is available. Try (tested on Win10):
Enable-WindowsOptionalFeature -Online -FeatureName "IIS-WebServerManagementTools" -All
Windows Server 2008 doesn't come with a PowerShell module for managing IIS. That feature was added with Windows Server 2008 R2. You need to download and install it first. See here for further information. See also this related question.
I am using Windows XP. Now i am having some issue which causing my PC to run slow. So very frequently i was need to go and delete some temporary files from the directory C:\WINDOWS\Temp . Any way to get it done with a script automatically?
Error
I get the below error when I tried to run the script from my machine:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\rakshiar>D:\WIPData\cleanup.ps1
C:\Documents and Settings\rakshiar>powershell.exe D:\WIPData\cleanup.ps1
File D:\WIPData\cleanup.ps1 cannot be loaded because the execution of scripts i
s disabled on this system. Please see "get-help about_signing" for more details
.
At line:1 char:23
+ D:\WIPData\cleanup.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
C:\Documents and Settings\rakshiar>
Thanks
you have to change your executionPolicy ( by default powershell not allow to run script), so strart powershell as administrator and run :
Set-ExecutionPolicy remotesigned
I use this powershell script to clean up a folder on my windows machine. It's run via scheduled tasks; use something like this as the command "powershell.exe &'c:\psbin\cleanup.ps1'".
$dir = "C:\SomeDirectory"
$d = [System.DateTime]::Now.AddDays(-1)
gci -recurse $dir | ?{ !$_.psiscontainer -and $_.LastWriteTime -lt $d } | %{ remove-item -Force $_.FullName }
This deletes files older than one day. Change the AddDays to change this.