Showing posts with label powershell. Show all posts
Showing posts with label powershell. Show all posts

Monday, 6 August 2012

Powershell : Import-Module : Could not load file or assembly

Sometimes you might face above issue while importing module(written using C# dll) downloaded from internet. One reason could be that, windows considers downloaded dll's as malicious or whatever, so just 'Unblock'(right-click into Properties->General tab) if you trust it.

Wednesday, 4 July 2012

CmdLet.ShouldContinue

Please refer this

Below example code

protected override void ProcessRecord()
{
    if (this.ShouldContinue("Are you sure you want to uninstall", "Confirm Uninstall"))
    {
        //your script here
    }
}

Monday, 23 April 2012

Sample powershell scripts

ProjectDir - Project Folder
OutDir - either bin\debug or bin\release or whatever set as output directory

1. To Copy files from 'some folder' into output directory  - below copies everything from 'libs' folder which is at same level as that of our Project directory into Project directory's output.

    copy /Y $(ProjectDir)\..\libs\* $(ProjectDir)\$(OutDir)\

to be contd....

Friday, 13 April 2012

BadImageFormatException in Windows 2008 R2 Server

I successfully imported PowerShell Script written using C#, but it throws System.BadImageFormatException when i tried to execute it. After spending few hours, figured out my Powershell Script was compiled for x86, so i should have used “c:\Windows\SysWOW64\WindowsPowerShell\v1.0”.