IT Questions and Answers :)

Sunday, August 25, 2019

Which statement about private clouds is true?

Which statement about private clouds is true?

  • They are more secure than public clouds
  • They are exclusively for a single organization
  • SLAs are not required
  • They do not use server virtualization 
Which statement about private clouds is true?

EXPLANATION

Private cloud refers to a model of cloud computing where IT services are provisioned over private IT infrastructure for the dedicated use of a single organization. A private cloud is usually managed via internal resources.
The terms private cloud and virtual private cloud (VPC) are often used interchangeably. Technically speaking, a VPC is a private cloud using a third-party cloud provider's infrastructure, while a private cloud is implemented over internal infrastructure.
Private clouds may also be referred to as enterprise clouds.

There is some controversy around the very idea of a private cloud. The central idea of cloud computing is an organization should not need to build out and manage computing infrastructure itself. By utilizing cloud vendors, an organization should lower costs while receiving services and applications that are on par or better than what could be done in-house. Given this, a private cloud would seem to be going backwards. An organization would still need to build out and manage the private cloud infrastructure and not get any benefits from the economies of scale that should come with cloud computing.
The flip side of this argument is that not all organizations can give up control to third-party vendors. A proponent of private clouds would argue there are still significant benefits to private clouds in the sense that a private cloud is a way to centralize large installations of IT infrastructure in a highly virtualized manner while avoiding exposure to the unknowns of an outside cloud vendor.

 


Share:

In PowerShell, which of the following is not a standard way to accept command line parameters (arguments) into a function?

In PowerShell, which of the following is not a standard way to accept command line parameters (arguments) into a function?

  • function <name> { param( [<type>]$<arg> ) [...] }
  • function <name> ( [<type>]$<arg> ) { [...] }
  • function <name> { $Global:<arg> [...] }
  • function <name> { $arg[0]; $arg[1] [...] } 
In PowerShell, which of the following is not a standard way to accept command line parameters (arguments) into a function?

EXPLANATION

Parameters

Script Parameters / Arguments (for scripts, functions and script blocks)
Pass arguments to a script or cmdlet by separating them with spaces:

PS C:\> Get-ChildItem -Path $env:windir -Filter *.dll -Recurse
This can be made a little more readable by breaking up long lines with PowerShell’s escape character:
PS C:\> Get-ChildItem `
  -Path $env:windir `
  -Filter *.dll `
  -Recurse

To pass multiple arguments to a script you can splat them:
$myargs = @{
  Path = "$env:windir"
  filter = '*.dll
  Recurse = $true
}
Get-ChildItem @myargs
The above will be expanded to: Get-ChildItem -Path $env:windir -Filter *.dll -Recurse

$args

Within a script or function you can refer to unnamed arguments using the $args array, for example passing all the arguments through to a cmdlet. You can also refer to specific arguments by their position:
"First argument is " + $Args[0]
"Second argument is " + $Args[1]

So if you call the script above like ./demoscript.ps1 "Alpha" "Beta", it will return:
"First argument is Alpha
"Second argument is Beta


Param

To define arguments by name, use a param statement, which is simply a comma separated list of variables, optionally prefixed with a [data type] and/or with = default values.
If used, the param statement MUST be the first thing in your script or function:
param (
    [string]$price = 100, 
    [string]$ComputerName = $env:computername,    
    [string]$username = $(throw "-username is required."),
    [string]$password = $( Read-Host -asSecureString "Input password" ),
    [switch]$SaveData = $false
)
write-output "The price is $price"
write-output "The Computer Name is $ComputerName"
write-output "The True/False switch argument is $SaveData"
Calling this script, and setting the switch parameter -SaveData to $TRUE:
.\demo.ps1 -ComputerName "\\server64" -SaveData
or setting -SaveData to $FALSE:
.\demo.ps1 -ComputerName "\\server64" -SaveData:$false

Parameter Attributes

In an Advanced Function, the params statement block can also optionally define parameter attributes:
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] 
These affect the function parameters as follows:
Mandatory - Whether the parameter is mandatory or optional (the default)
ValueFromPipeline - Accept values via the pipeline, of the same type expected by the parameter or that can be converted to the type that the parameter is expecting.
ValueFromPipelineByPropertyName - Accept values via the pipeline of the same type expected by the parameter and which also must have the same name as the parameter accepting pipeline input.
An Advanced Function is one that contains either a [cmdletbinding()] attribute or the Parameter attribute, or both.
cmdletbinding adds several capabilities such as additional parameter checking, and the ability to easily use Write-Verbose.
A function with cmdletbinding will throw an error if unhandled parameter values appear on the command line.

Defaults in PowerShell 3.0 and above

In PowerShell 3.0 if an arguments default value is omitted, there is an implied default value of $true you can use this to shorten both params and parameter attributes, (n.b. leaving out the = $true in this way will prevent the script from running in PowerShell 1.0 or 2.0)
Param (
   [Parameter(ValueFromPipelineByPropertyName)]
   [string] $DemoParameter
)

Cmdlet Parameters

Almost every PowerShell cmdlet can accept one or more optional parameters which can be supplied on the command line in the form -Parameter_Name Parameter_Value
The name of the parameter is always preceded by a hyphen (-)

The Parameter_value often needs to be provided in a specific data type (e.g. string or integer)
To find these details use Get-Help -detailed cmdletName
In some cases, the Parameter_Name is implied and does not need to be explicitly included.
In syntax descriptions:
 [-Param] -- is optional 
  -Param  -- is required
If you exclude the Parameter Names you must ensure that the Parameter Values are listed in the correct order (assuming more than one value is being passed .)
Parameter Names will be ignored if contained in quotation marks.
Multiple values (for the same parameter) can be separated with commas.

Parameters for external commands

When calling a non-PowerShell command or CMD utility then the parameters won't follow any PowerShell conventions,
Generally any arguments to external commands should be surrounded in quotes if needed due to spaces/long filenames (just like the CMD shell) or if any part of the command uses characters that have a special meaning to PowerShell such as brackets ( ) or { } s
See the & CALL operator page for more ways to execute a command, script or function.
“Slow down and enjoy life. It's not only the scenery you miss by going too fast, you also miss the sense of where you are going and why” - Eddie Cantor
Related PowerShell Cmdlets:
help about_Functions_Advanced_Parameters

 

Share:

Which of the following command-line strings lists the mapped drives in Windows?

Which of the following command-line strings lists the mapped drives in Windows?

  • showdr
  • net use
  • show folder
  • drlocation 
Which of the following command-line strings lists the mapped drives in Windows?

EXPLANATION


The net use command is a Command Prompt command that's used to connect to, remove, and configure connections to shared resources, like mapped drives and network printers.
The net use command is one of many net commands like net send, net time, net user, net view, etc.

Net Use Command Availability

The net use command is available from within the Command Prompt in Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP, as well as in older versions of Windows and in Windows Server operating systems.
Recovery Console, the offline repair utility in Windows XP, also includes the net use command but it's not possible to use it within the tool.
The availability of certain net use command switches and other net use command syntax may differ from operating system to operating system.

Net Use Command Syntax

net use [{devicename | *}] [\\computername\sharename[\volume] [{password | *}]] [/user:[domainname\]username] [/user:[dotteddomainname\]username] [/user:[username@dotteddomainname] [/home {devicename | *} [{password | *}]] [/persistent:{yes | no}] [/smartcard] [/savecred] [/delete] [/help] [/?]
It will be important to know how to read command syntax if you're not sure how to interpret the net use command syntax as it's shown above or described in the table below.

Net Use Command Options
Option Explanation
net use Execute the net use command alone to show detailed information about currently mapped drives and devices.
devicename Use this option to specify the drive letter or printer port you want to map the network resource to. For a shared folder on the network, specify a drive letter from D: through Z:, and for a shared printer, LPT1: through LPT3:. Use * instead of specifying devicename to automatically assign the next available drive letter, starting with Z: and moving backward, for a mapped drive.
\\computername\sharename This specifies the name of the computer, computername, and the shared resource, sharename, like a shared folder or a shared printer connected to computername. If there are spaces anywhere here, be sure to put the entire path, slashes included, in quotes.
volume Use this option to specify the volume when connecting to a NetWare server.
password This is the password needed to access the shared resource on computername. You can choose to enter the password during the execution of the net use command by typing * instead of the actual password.
/user Use this net command option to specify a username to connect to the resource with. If you don't use /user, net use will attempt to connect to the network share or printer with your current username.
domainname Specify a different domain than the one you're on, assuming you're on one, with this option. Skip domainname if you're not on a domain or you want net use to use the one you're already on.
username Use this option with /user to specify the username to use to connect to the shared resource.
dotteddomainname This option specifies the fully qualified domain name where username exists.
/home This net use command option maps the current user's home directory to either the devicename drive letter or the next available drive letter with *.
/persistent:{yes | no} Use this option to control the persistence of connections created with the net use command. Choose yes to automatically restore created connections at the next login or choose no to limit the life of this connection to this session. You can shorten this switch to /p if you like.
/smartcard This switch tells the net use command to use the credentials present on the available smart card.
/savecred This option stores the password and user information for use next time you connect in this session or in all future sessions when used with /persistent:yes.
/delete This net use command is used to cancel a network connection. Use /delete with devicename to remove a specified connection or with * to remove all mapped drives and devices. This option can be shortened to /d.
/help Use this option, or the shortened /h, to display detailed help information for the net use command. Using this switch is the same as using the net help command with net use: net help use.
/? The standard help switch also works with the net use command but only displays the command syntax, not any detailed information about the command's options.











Share:

How do you delete 4 lines using the "vi" Unix editor?

How do you delete 4 lines using the "vi" Unix editor?

  • y4
  • 4<delete-key>
  • 4x
  • 4dd 

EXPLANATION

I am using putty and vi editor if select 5 lines using mouse and i want to delete those lines how can i do that
Forget the mouse. To remove 5 lines, either:

  • Go to the first line and type d5d (dd deletes one line, d5d deletes 5 lines) ~or~
  • Type Shift-v to enter linewise selection mode, then move the cursor down using j (yes, use h, j, k and l to move left, down, up, right respectively, that's much more efficient than using the arrows) and type d to delete the selection.
Also how can i select the lines from keyboard like in windows i pres shift and move the arrows to select the text. how can i do that in vi
As I said, either use Shift-v to enter linewise selection mode or v to enter characterwise selection mode or Ctrl-v to enter blockwise selection mode. Then move with h, j, k and l.
I suggest spending some time with the VIM Tutor (run vimtutor) to get more familiar with VIM in a very didactic way.

See also

 

Share:

What does DOS stand for?

What does DOS stand for?

  • Direct operating system
  • Disk operating system
  • Direct operation system
  • Drive operating system 
What does DOS stand for?

EXPLANATION

DOS (Disk Operating System)

DOS (Disk Operating System) is an operating system that runs from a hard disk drive. The term can also refer to a particular family of disk operating systems, most commonly MS-DOS (Microsoft Disk Operating System).

An operating system (OS) is the software that controls a computer's hardware and peripheral devices and allows other programs to function. Early computers did not have disk drives but were hard-wired to carry out specific computations. Later, computers were able to store instructions loaded into the computer's memory using punch cards and later magnetic tapes. Computer memory space was limited and when the instructions to control a computer were moved onto a disk drive, such as a floppy disk or internal hard drive, it was considered cutting-edge technology. Today, any modern operating system would be considered a disk operating system.

Disk operating system is also used to describe several very similar command line disk operating systems. PC-DOS (Personal Computer Disk Operating System) was the first widely-installed disk operating system used in personal computers running on Intel 8086 16-bit processors. It was developed for IBM by Microsoft Corporation, which also produced its own almost identical version called MS-DOS. Other computers at the time, such as the Commodore 64, Atari 800, and Apple II, all featured a disk operating system, CBM DOS, Atari DOS, and Apple DOS, respectively. (DOS/360 was an operating system for IBM mainframes which first appeared in 1966, but is unrelated to the 8086-based DOS of the 1980s.

These early operating systems did not multitask, as they were only able to run one program at a time. The command line interface, in which a user has to type in commands, required the user to remember commands to run programs or do other operating system tasks, making it difficult for novices to use. For example, typing the command "cd \directory_name" changed the current working directory to the named directory and typing the command "dir" listed the files in the current directory.

When Microsoft first introduced Windows as a graphical user interface (GUI) for MS-DOS, early users had to type "WIN" at the DOS prompt to launch the Windows program. Windows has since evolved from being a GUI program running under DOS to a full operating system taking over as the default OS, though it was not until Windows XP that consumer versions of Windows stopped relying on the DOS program win.com to bootstrap the Windows kernel.

The last retail version of MS-DOS was MS-DOS 6.22. After this release, MS-DOS was still bundled as part of Windows, but no longer required a separate license. It can still be run under Windows using the Command Prompt program. There is an open source version of DOS called FreeDOS which is based on and compatible with MS-DOS.
Note: The acronym DoS with a lowercase O is short for Denial of Service, a method of attacking a networked computer by sending it an abnormally high number of requests in order to exhaust its resources so that genuine users cannot gain access.

Share:

Popular Posts