Change Local Disk Name Using PowerShell

Chirag Nagrekar
Updated on 25-Jan-2021 07:23:14

4K+ Views

To change the local disk name using PowerShell, we can use the Set−Volume command. For example, we have Drive name F and its volume label is “New Volume” and need to change it to the “Temporary Storage” then we can change the label using its existing volume name or with the Drive letter.To change the volume name with the Drive letter, Set−Volume −DriveLetter 'E' −NewFileSystemLabel 'Temporary Storage'To change it with the existing label, Set−Volume −FileSystemLabel 'New Volume' −NewFileSystemLabel 'Temporary Storage'For the remote system, we can use either Invoke−Command or the CIMSession parameter.For example, $sess = New−CimSession −ComputerName Labmachine2k12 Set−Volume −CimSession ... Read More

Create Test Datasets Using Scikit-Learn in Python

Pradeep Elance
Updated on 25-Jan-2021 07:19:19

356 Views

The Sklearn python library does provide sample data sets which can be used tocreate various graph plots. The usefulness of these datasets is in creating sample graphs and charts and predicting the behavior of the graph as the values changes. Also you can work on other parameters like deciding on the colours and axes etc on this sample graphs before using the actual data set.Using make_blobsIn the below example we use the sklearn library along with the matplotlib to create a scatter plot with a specific style. We choose a sample of 200 data points and also select the colour ... Read More

Install NuGet Package Using PowerShell

Chirag Nagrekar
Updated on 25-Jan-2021 07:18:40

21K+ Views

Nuget is the package management tool for the .NET and it is similar to PowerShellGet, MSI packages which support several commands and packages to work with PowerShell.NuGet supports Install−Package, Update−Package, Find-Package, and Get−Package command and if Nuget package is not installed in your system, you may not find a package or install any package.For more reference about Nuget, check the websites below.https://www.nuget.orghttps://docs.microsoft.com/en-us/nuget/reference/powershellTo install NuGet, we need to use the Install−PackageProvider command. Use the below command to install the Nuget package.Install−PackageProvider −Name Nuget −ForceOn some machines, you will get the error message regarding downloading the package from the internet. If you ... Read More

Find Maximum Length Sub-List in a Nested List in Python

Pradeep Elance
Updated on 25-Jan-2021 07:18:06

952 Views

we often deal with nested lists when doing data analysis in python. In this article, we will see how to find out the longest list among the elements in a nested list and then print this along with its length.Using lambda and mapWe declare a nested list and give it as input to the lambda function along with its length. Finally, we apply the max function to get the list with maximum length as well as the length of such list.Example Live Demodef longest(lst):    longestList = max(lst, key = lambda i: len(i))    maxLength = max(map(len, listA))    return longestList, ... Read More

Change Drive Letter Using PowerShell

Chirag Nagrekar
Updated on 25-Jan-2021 07:15:34

2K+ Views

To change the drive letter using PowerShell, we can use the Set−Partition command but before that, we need to know which drive letter to change. You can check the drive letter using Windows Explorer, Get−Partition, Gwmi win32_Logicaldisk, or Get−CimInstance Win32_Logicaldisk command.Suppose we have an E: and we need to rename its drive letter to F, so we can use the below command.Set−Partition −DriveLetter 'E' −NewDriveLetter 'F'Make sure that the drive is not in use by Pagefile, open application, or open file from the drive otherwise the drive letter will fail to change.To change the drive letter on the remote computer, ... Read More

Get Disk Information Using PowerShell

Chirag Nagrekar
Updated on 25-Jan-2021 07:15:06

7K+ Views

To get the Windows disk information using PowerShell, we can use the WMI command or the CIM class command.With the WMI command, Gwmi Win32_LogicalDiskWith the CIM instance method, Get−CimInstance Win32_LogicalDisk You can see both the outputs are identical. Let’s use one of them.DeviceID DriveType ProviderName VolumeName Size FreeSpace -------- --------- ------------ ---------- ---- --------- C: 3 53317988352 44027125760 D: 5 HRM_SSS_X64FREE_EN-US_DV5 3694962688 0 E: 3 Temporary Storage 10734268416 10238513152Now there are different drive types associated with Windows and they each have an identical number. For example, Drive Type ‘3’ mentions the logical disk. The other types are as below.2 = ... Read More

Creating a Proxy Webserver in Python

Pradeep Elance
Updated on 25-Jan-2021 07:14:41

2K+ Views

A proxy server sits in between the client and the actual server. It receives the requests from the client, send it to the actual server, and on receiving the response from the actual server it sends the response back to the client. There are many reasons to use the proxy like hiding the server’s IP address, performance improvement or increasing security etc. In this article we will see how we can create a simple proxy server using python.The three modules SimpleWebSocketServer, , SimpleHTTPSServer and urllib can be used to achieve this. Below we see how we create python class using ... Read More

Ways to Use Where-Object in PowerShell

Chirag Nagrekar
Updated on 25-Jan-2021 07:11:07

2K+ Views

Where−Object or (alias: Where) in PowerShell is used to filter the data output provided through the Pipeline.There are two methods we can use the Where−Object for the pipeline inputs.a. ScriptMethod −In this method, we use ScriptBlock to filter the output with the Property name, value, and the comparison operator.Get−Service | Where−Object{($_.StartType −eq 'Automatic') −and ($_.Status −eq 'Stopped')}You can also use Alias: Where instead of Where−Object.Get−Service | Where{($_.StartType −eq 'Automatic') −and ($_.Status −eq 'Stopped')} Other Syntax ‘?’ (Question Mark) can also be used Instead of the Where−Object command.Get−Service | ?{($_.StartType −eq 'Automatic') −and ($_.Status −eq 'Stopped')}The above commands will get the ... Read More

Convert One String into Another String in C++

sudhir sharma
Updated on 25-Jan-2021 05:29:05

261 Views

In this problem, we are given two strings str1 and str2. Our task is to create a program to Print all possible ways to convert one string into another string. Problem Description: Here, we need to find all possible ways using which we can convert str1 to str2. While converting, we can perform any of the three operations, Insert RemoveReplaceLet’s take an example to understand the problem,  Input: str1 = “kfeod” str2 = “kfcadq”OutputWay1:Insert q, after d. Replace c by e. Replace o by a.Solution ApproachWe will find the minimum number of edits first and then create a DP matrix. Then check if the character ... Read More

Print BST Keys in Given Range in O(1) Space using C++

sudhir sharma
Updated on 25-Jan-2021 05:28:31

129 Views

In this problem, we are given two values k1 and k2 (k1 < k2), and the root of the binary search tree. Our task is to create a program to Print BST keys in given Range. Problem Description: We will print all the keys of the tree from n1 to n2 in increasing order.Let’s take an example to understand the problem,  Input: k1 = 4, k2 = 12Output: 6, 7, 9Solution ApproachSimple we can solve the problem using inorder traversal but the space complexity there is 0(n) but the need of the hour is to solve in O(1) complexity. So, for this, we will use a ... Read More

Advertisements