Docker basic CheatSheet

https://docs.docker.com/get-started/

  • Install Docker:
  • Test Docker: docker run hello-world
  • Help:
    • docker –version
    • docker –help
    • docker COMMAND –help
  • Commands:
    • Show available images: docker images
    • Show containers: docker ps (docker container ls)
    • Manage containers:
      • List: docker container ls
      • Stop: docker container stop dsa34ewqe
      • Force stop: docker container kill dsa34ewqe
      • Remove: docker container rm dsa34ewqe
      • Execute bash: docker exec -it dsa34ewqe bash
      • Remove
    • Manage images:
      • List image: docker image ls
      • Remove image: docker rmi ubuntu/latest
      • Remove all images: docker rmi $(docker images -a -q)
      • Dangling images:
        • List: docker images -f dangling=true
        • Delete: docker images purge
      • Create image: docker build -t friendlyhello .
      • Run image:
        • docker run -d -p 4000:80 friendlyhello
        • docker run -d -p 4000:80 cadvga/get-started:part2
    • Manage compose:
      • docker-compose up -d

Function to prepare Machine.config

This PowerShell script “prepare” machine.config by:

  • Create appSettings.config and link it in machine.config
  • Create connectionStrings.config and link it in machine.config
  • Add proxy settings

Code:

 

 

 

 

 

 

Main base Powershell script (with Azure)

Example of PowerShell Main base script with detection of PowerShell version and Azure PowerShell version.

 

 

PowerShell new features.

PowerShell 5.0 (Windows Management Framework 5.0)

  • By default in Windows 10 & Windows Server 2016 Technical Preview.
  • Remote Script Debugging in ISE 🙂
  • Transcription works in ISE by default
  • .NET enumerations.
  • Improved DSC.

PowerShell 4.0

  • By default in Windows 8.1 & Windows Server 2012 R2
  • DSC: Desired State Configuration
  • Remote Script Debugging in console (no ISE)
  • Improved Invoke-RestMethod and Invoke-WebRequest to specify headers.

PowerShell 3.0

  • By default in Windows 8 & Windows Server 2012
  • Improved ISE: IntelliSense
  • Improved remote PowerShell ( New-PSSession)
  • Module Auto-Load
  • Invoke-RestMethod and Invoke-WebRequest
  • Ordered Hashtables
  • Scheduled jobs

PowerShell Modules: All you need to remember

 

Script Modules

A script module is a file (.psm1) that contains any valid Windows PowerShell code. Script developers and administrators can use this type of module to create modules whose members include functions, variables, and more.

Binary Modules

A binary module is a .NET Framework assembly (.dll) that contains compiled code. Cmdlet developers can use this type of module to create modules that contain cmdlets, providers, and more. (Existing snap-ins can also be used as binary modules.)

Manifest Modules

A manifest module is a module that includes a manifest (described later in this section) to describe its components, but that does not specify a root module in the manifest. A module manifest does not specify a root module when the ModuleToProcess key of the manifest is blank. In most cases, a manifest module also includes one or more nested modules using script modules or binary modules. A manifest module that does not include any nested modules can be used when you want a convenient way to load assemblies, types, or formats.

Dynamic Modules

A dynamic module is a module that does not persist to disk. This type of module enables a script to create a module on demand that does not need to be loaded or saved to persistent storage. By default, dynamic modules created with the New-Module cmdlet (described in the following sections) are intended to be short-lived and therefore cannot be accessed by the Get-Module cmdlet

Using Transfer utility in AWS SDK.NET

Useful Links

Upload files

Upload directory

 

 

Function to change encoding of a file in PowerShell

This is a function to change encoding of a file:

Function to check if MarkLogic is up

Function to quickly see if MarkLogic is up and running

Taken from my unsuccessful StackOverflow answer 🙂

 

Function to SmartCreate Folder in Powershell

Function to create a folder in Powershell if it doesn’t exist or recreate if it exists

 

Execute function in remote Computer

This is an example of how to execute PowerShell remote code and pass parameters: