How to delete your Azure Directory

The easy Way.

We all seen this before, but Delete all App registrations can be a pain.

Before you move or delete your subscription

Delete all App registrations in App registrations (Legacy).

Then fire up powershell in the portal.  

All remaining app registration will be deleted.

offset And Tiling in Unity

Create a plane in unity.

add Standart material and assign a image in Main Maps / Albedo.

Image:

your material in inspector:

to make it moving along the plane, create the following C# script.

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class offsetTillingPlane : MonoBehaviour {

public float scrollSpeed = 0.5F;

Renderer rend;

// Use this for initialization

void Start () {
rend = GetComponent<Renderer>();

}

// Update is called once per frame
void Update () {

float offset = Time.time * scrollSpeed;
rend.material.mainTextureOffset = new Vector2(offset, 0);
       }
}

attach the script to the plane (Pres Play)

 

Powershell and Excel

some times it will be nice to export data to Excel.

to open Excel from power shell and set a Heading.

Try the following

$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()

$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Name = “MySheet”
$Sheet.Cells.Item(1,1) = “MyTestheading”
#$Sheet.Cells.Item(1,2) = “You”
#$Sheet.Cells.Item(1,3) = “Get”
#$Sheet.Cells.Item(1,4) = “The”
#$Sheet.Cells.Item(1,5) = “Code”
$WorkBook = $Sheet.UsedRange
#Background color in cell
$WorkBook.Interior.ColorIndex = 37
#Text color in cell
$WorkBook.Font.ColorIndex = 0
$WorkBook.Font.Bold = $True

The code will open Excel create a sheet call MySheet and set a heading call MyTestheading.

Lets fill some data in

#data
$datain = (“Microsoft”,”Apple”,”IBM”,”Redhat”,”Novell”)
# Row Counter / we use row 1 for our Heading.
$intRow = 2
foreach ($line in $datain) {

$Sheet.Cells.Item($intRow,1) = ($line)

$intRow = $intRow + 1

}

# Autofitter
$WorkBook.EntireColumn.AutoFit()

 

The code will open Excel create a sheet call MySheet and set a heading call MyTestheading and put our data in.

 

to be continued

How to Write a Class in PowerShell

 

To make it simple we will Create a Class

Instantiate an Object of  our class and fill data into to the object.

Write the code in powershell ise and run it.

 

$QuickTest = New-Object Card

Class Card
{

[String]$Firstname
[String]$Lastname
[String]$Adress
[int]$Phone

}

 

to check our class object write $QuickTest

Lets fill some data in.

write $QuickTest to see the changes

You now know howto create a class  Instantiate an object of our class and fill it with data.

 

How to Write a PowerShell Module in visual studio 2017

Create an project in visual studio, let’s call it MyPmTest

Try to build you solution and import the module.

Start a PowerShell prompt

Write Import-Module .\ MyPmTest.psm1

If success Write Get-Module

You can see the default Get-Function already.

Change to visual studio and change you function name

rebuild your solution and reimport the module.

Start a PowerShell prompt

Write Import-Module .\ MyPmTest.psm1

If success Write Get-Module

You can now see that you default Get-Function are gone and you got 2 new functions

Get-MyTest01 and Get-MyTest02

Try to write Get-MyTest01 and Get-MyTest02

Congrats you have created your first PowerShell module and imported it and run 2 function.

Not bad for 5 minutes’ work.

Unity instantiate random prefab

//How to Instantiate difference prefab at runtime in Unity.

//Create a C# script and create a array

public GameObject[] prefeb;
//go in inspector in unity set size and drag the prefabs to the Element.
//create a function in same script and call it
void createdifobjects()
{
int prefeb_num = Random.Range(0, 3);
Instantiate(prefeb[prefeb_num], this.transform.position , this.transform.rotation);
}