Tutorial by Examples

This is a unit test of a component that has Store as a dependency. Here, we are creating a new class called MockStore that is injected into our component instead of the usual Store. import { Injectable } from '@angular/core'; import { TestBed, async} from '@angular/core/testing'; import { AppComp...
This is a unit test of a component that has Store as a dependency. Here, we are able to use a store with the default "initial state" while preventing it from actually dispatching actions when store.dispatch() is called. import {TestBed, async} from '@angular/core/testing'; import {AppCom...
While the basic invocation above is easy enough, the curses package provides the wrapper(func, ...) helper function. The example below contains the equivalent of above: main(scr, *args): # -- Perform an action with Screen -- scr.border(0) scr.addstr(5, 5, 'Hello from Curses!', curses...
//By range address worksheet.Cells["A1:B5"].Merge = true; //By indexes worksheet.Cells[1,1,5,2].Merge = true;
Detailed instructions on getting ssrs-2008 set up or installed.
This installation assumes hadoop to be pre-installed under hadoop user. Prerequisites: Hue depends on these following packages gcc g++ libxml2-dev libxlst-dev libsasl2-dev libsasl2-modules-gssapi-mit libmysqlclient-dev python-dev python-setuptools libsqlite3-dev ant libkrb5-dev libt...
Detailed instructions on getting installshield set up or installed.
Get-ChildItem -Path $PSScriptRoot This example retrieves the list of child items (directories and files) from the folder where the script file resides. The $PSScriptRoot automatic variable is $null if used from outside a PowerShell code file. If used inside a PowerShell script, it automatically ...
$Args Contains an array of the undeclared parameters and/or parameter values that are passed to a function, script, or script block. When you create a function, you can declare the parameters by using the param keyword or by adding a comma-separated list of parameters in parentheses after the...
Get-Process | ForEach-Object -Process { $PSItem.Name } Same as $_. Contains the current object in the pipeline object. You can use this variable in commands that perform an action on every object or on selected objects in a pipeline.

$?

Get-Process -Name doesnotexist Write-Host -Object "Was the last operation successful? $?" Contains the execution status of the last operation. It contains TRUE if the last operation succeeded and FALSE if it failed.
Get-Process -Name doesnotexist Write-Host -Object ('The last error that occurred was: {0}' -f $error[0].Exception.Message) Contains an array of error objects that represent the most recent errors. The most recent error is the first error object in the array ($Error[0]). To prevent an error fr...
[DscResource()] class File { } This example demonstrates how to build the outer section of a PowerShell class, that declares a DSC Resource. You still need to fill in the contents of the class definition.
[DscResource()] class Ticket { [DscProperty(Key)] [string] $TicketId } A DSC Resource must declare at least one key property. The key property is what uniquely identifies the resource from other resources. For example, let's say that you're building a DSC Resource that represents a ticket...
[DscResource()] class Ticket { [DscProperty(Key)] [string] $TicketId [DscProperty(Mandatory)] [string] $Subject } When building a DSC Resource, you'll often find that not every single property should be mandatory. However, there are some core properties that you'll want to ensure ...
[DscResource()] class Ticket { [DscProperty(Key)] [string] $TicketId # The subject line of the ticket [DscProperty(Mandatory)] [string] $Subject # Get / Set if ticket should be open or closed [DscProperty(Mandatory)] [string] $TicketState [void] Set() { # Creat...
@{ RootModule = 'MyCoolModule.psm1' ModuleVersion = '1.0' CompatiblePSEditions = @('Core') GUID = '6b42c995-67da-4139-be79-597a328056cc' Author = 'Bob Schmob' CompanyName = 'My Company' Copyright = '(c) 2017 Administrator. All rights reserved.' Description = 'It does cool stu...
function Add { [CmdletBinding()] param ( [int] $x , [int] $y ) return $x + $y } Export-ModuleMember -Function Add This is a simple example of what a PowerShell script module file might look like. This file would be called MyCoolModule.psm1, and is referenced from the mod...
$FirstName = 'Bob' Export-ModuleMember -Variable FirstName To export a variable from a module, you use the Export-ModuleMember command, with the -Variable parameter. Remember, however, that if the variable is also not explicitly exported in the module manifest (.psd1) file, then the variable wil...
Rather than defining all of your functions in a single .psm1 PowerShell script module file, you might want to break apart your function into individual files. You can then dot-source these files from your script module file, which in essence, treats them as if they were part of the .psm1 file itself...

Page 1097 of 1336