Software & Coding Articles

Page 65 of 83

How to view folder NTFS permission with PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 28-Sep-2020 4K+ Views

To view the NTFS permission with PowerShell, we use the Get-ACL command. This command is supported in PowerShell version 5.1 or later. Generally how we get the security permission of the folder in the Windows OS using GUI, To get the same permissions shown above using PowerShell, use the below command.Get-Acl C:\SharedPS C:\> Get-Acl C:\Shared Directory: C:\ Path      Owner     Access ----      -----     ------ Shared BUILTIN\Administrators NT AUTHORITY\SYSTEM Allow FullControl...You can compare the first image with the above output. You can compare the Owner of the folder and it ...

Read More

What is the use of the Get-Error cmdlet in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 19-Sep-2020 866 Views

Get-Error cmdlet was introduced in PowerShell v7. It displays the most recent error messages from the current session.When you check the get member of this command, its output is in the form of PSExtendedError so whatever the output is produced by this command is in a detailed manner and so this command is very helpful in troubleshooting error messages.PS C:\> Get-Error | gm TypeName: System.Management.Automation.ErrorRecord#PSExtendedErrorWe will write one command in the PowerShell console which is ultimately generate an error.PS C:\> Get-ChildItem c:otexist Get-ChildItem: Cannot find path 'C:otexist' because it does not exist.The above directory does not exist. Let’s get a ...

Read More

Which are the new Null Operators introduced in PowerShell version 7?

Chirag Nagrekar
Chirag Nagrekar
Updated on 19-Sep-2020 295 Views

PowerShell version 7 has introduced a few new null operators. They are as below.Null-Coalescing operator - ??Null Conditional Assignment Operators - ??=Null Conditional member access operators - ?. and ?[]a. Null-Coalescing operator - ??Null Coalescing operator ??evaluates the left-hand side condition or operand and if it is null then evaluates the right-hand side operand otherwise provides the value of the left-hand side operand.For example, Without the Null-Coalescing operator, we would have written a script like as shown below, $Name = $null if($Name -eq $null){"Name is Null"} Else {"PowerShell"}The above same condition can be written with the ?? operator.$name = $null ...

Read More

How to use the ValidateCount attribute in PowerShell Function?

Chirag Nagrekar
Chirag Nagrekar
Updated on 19-Sep-2020 568 Views

The validateCount attribute in PowerShell function is to validate the length of an array, which means that you can pass the specific number of arguments into the parameter. In the below example we need array should contain a minimum 1 and maximum 4 values when we pass the values. For that, we will write the below script, Function ValidateArray {    Param (       [ValidateCount(1, 3)]       [String[]]$Animals    )    return $PSBoundParameters }OutputPS C:\> ValidateArray -Animals Cow, Dog, Cat Key Value --- ----- Animals {Cow, Dog, Cat}The above output is valid but when we pass ...

Read More

How to use the ValidateScript attribute in PowerShell function?

Chirag Nagrekar
Chirag Nagrekar
Updated on 19-Sep-2020 2K+ Views

The ValidateScript attribute is to validate the script before entering inside the function. For example, let say you want to validate the path of the file, validate the remote computer connectivity, etc. We will take here remote server connectivity example.Without the ValidateScript attribute, we would have written the script as shown below.Function Check-RemoteServer {    param (       [string]$Server    )    if(Test-Connection -ComputerName $Server -Count 2 -Quiet -ErrorAction Ignore) {       Write-Output "$server is reachable"    } else {       Write-Output "$Server is unreachable"    } }OutputPS C:\> Check-RemoteServer -Server asde.asde asde.asde is ...

Read More

How to use the ValidateLength attribute in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 19-Sep-2020 494 Views

The ValidateLength attribute in PowerShell is used to validate the length of the String. Generally how we write the command without the mentioned attribute is using the Length method and if/else condition for the string. For Example, Function ValidateStorageName {    param (       [String]$StorageName    )    if(($StorageName.Length -gt 3) -and ($StorageName.Length -lt 15)) {       Write-Output "`nStorage Name validated"    } else {       Write-Output "`nStorage Name validation failed"    } }Output−PS C:\> ValidateStorageName -StorageName Alpha Storage Name validated PS C:\> ValidateStorageName -StorageName CN Storage Name validation failedWith the ValidateLength attribute, else ...

Read More

How to use the ValidateSet Attribute in PowerShell function?

Chirag Nagrekar
Chirag Nagrekar
Updated on 19-Sep-2020 5K+ Views

The ValidateSet attribute in PowerShell function is to validate the values entered from the set which means, it allows only specific values from the set. To understand better consider the below example, we have an array and we need to check if entered values are among array or not then we will use the below code.Function PetAnimalsCheck {    param(       [String]$Animal    )    $Animals = "Cow", "Dog", "Cat", "Horse", "Camel", "Elephant"    if($Animals -contains $Animal) {       Write-Output "Animal is in the list of Pet Animals"    } else {       Write-Output ...

Read More

How to use the ValidateRange attribute in PowerShell function?

Chirag Nagrekar
Chirag Nagrekar
Updated on 19-Sep-2020 2K+ Views

Validation parameters are a set of rules that you define on the PowerShell variable and restrict users from entering some values and binding users to enter values in the specific domain. If there are not validation parameters the script would be lengthy. The ValidateRange attribute is one of them.ValidateRange AttributeThis parameter is to validate the specific range of numbers. For example, If we need users to enter a value between 5 and 100 and we simply write the script using the If/else statement as shown below.function AgeValidation {    param(       [int]$age    )    if(($age -lt 5) ...

Read More

Difference between Oracle 11g and Oracle 12c

Himanshu shriv
Himanshu shriv
Updated on 09-Sep-2020 7K+ Views

Oracle 12c is just upgraded version of the Oracle 11g with some new features like cloud support and pluggable database, kind of like master slave architecture. With the Oracle 12 c, you can plug your database to cloud anytime. It has multiple new features like JSON support, multitenant architecture and etc.Sr. No.KeyOracle 11gOracle 12c1BasicIt was released in released in 2008 and has no pluggable databaseIt is High performance RDbMS which is released in 2014. It is pluggable database.2Identity columnWe can't set primary key to raise automaticallyWe can set primary key to rise automatically.3JSON typeWe can't store Json directly to the ...

Read More

Difference between Docker Swarm and Kubernetes

Himanshu shriv
Himanshu shriv
Updated on 09-Sep-2020 649 Views

Docker Swarm and Kubernetes both can be used for similar purpose. They both are container orchestration tool.Docker Swarm is a tool used for clustering and scheduling Docker containers. We can easily establish and manage a cluster of Docker nodes under a single virtual system.Kubernetes is also container orchestration tool which is developed by google. It can be used for automatic deployment ,scaling, load balancing  and logging and monitoring.Sr. No.KeyDocker SwarmKubernetes1BasicKubernetes is also container orchestration tool which is developed by google. It can be used for automatic deployment ,scaling, load balancing  and logging and monitoring.Docker Swarm is a tool used for ...

Read More
Showing 641–650 of 825 articles
« Prev 1 63 64 65 66 67 83 Next »
Advertisements