Skip to content

Instantly share code, notes, and snippets.

function Increment
{
Param([int] $number)
$result = $number+1
$result
}
Write-Host "And the answer is" (Increment 41)
using System;
namespace ConsoleApplication
{
public class Program
{
public static int Increment(int number)
{
return ++number;
}
function SimpleFunction
{
Out-Host "Hello method host"
}
SimpleFunction
using System;
namespace ConsoleApplication
{
public class Program
{
public static void SimpleMethod()
{
Console.WriteLine("Hello Method World!");
}
$items | foreach { Write-Host "$_ has a length of" $_.Length }
$items | Write-Host
while((Get-Random -Minimum 1 -Maximum 100) -gt 50)
{
Write-Host "While... Random seems to be bellow 50."
}
Do
{
Write-Host "Do While... Random seems to be bellow 50."
} while((Get-Random -Minimum 1 -Maximum 100) -gt 50)
using System;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
while (new Random().Next(0, 50) > 50)
{
$currentDate = Get-Date
$messageOfTheDay = ""
if($currentDate.Day % 2 -ne 0)
{
$messageOfTheDay = "Today is an odd Day, "
}
else
{
$messageOfTheDay = "Today all should be even, "
using System;
using System.Text;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
StringBuilder messageOfTheDay = new StringBuilder();