search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell | No Comment | 1,662 views | 02/08/2012 07:10

Will Kruss reported an important bug of SetLinuxVM v4.4.
It’s not working on Windows Server 2008 and R2 due to PowerShell v2.
I’ve changed my development environment to Windows Server 2012 and Powershell v3. But I’ve fixed all compability issues.

Please download SetLinuxVM v4.5 for PowerShell v2 support.

You can also upgrade your Powershell version on Windows Server 2008 R2 to Powershell v3.


Posted in Windows Powershell | No Comment | 1,600 views | 01/08/2012 13:42

C# ile ilgili kendime bazı notlarım:

String Builder:

StringBuilder SB = new StringBuilder();
            SB.AppendFormat("Get-VM -Id {0} | Set-VM ", Id);

If / Else yazma:

if (ProcessorCount > 0)
                SB.AppendFormat("-ProcessorCount {0} ", ProcessorCount);

Or kullanımı ve eğer null ise:

if (string.IsNullOrEmpty(MemoryStartupBytes) || string.IsNullOrEmpty(MemoryStartupBytes))
                sadsadsadasdada
            else if (bla bla)
                sdsdsadsadsada
            else

Class yaratma:

class NewVMResult
    {
        public string VMId { get; set; }
        public string VMName { get; set; }
    }

Powershell çalıştırma:

static NewVMResult NewVM(string Name, string Path)
        {
            IEnumerable<dynamic> PSResult = PSShell.AddCommand("New-VM")
                                                   .AddParameter("Name", Name)
                                                   .AddParameter("Path", Path)
                                                   .Invoke();
 
            var PSObject = PSResult.FirstOrDefault();
            return new NewVMResult() { VMId = PSObject.Id.ToString(), VMName = PSObject.VMName };            
        }

C# yeni başladığım için kendime not düştüm :)