Test WinRM Connectivity Using PowerShell

Chirag Nagrekar
Updated on 25-Jul-2020 11:26:53

15K+ Views

In system admin role or as a PowerShell engineer you need to connect to many computers remotely. So as the first step, we need to test the remote connectivity by applying ping command or Test-Connection but many organizations have a stringent policy, and some of the servers ICMP packets are blocked. In such a case you can check connectivity with WINRM.If the WINRM is not allowed, you can ask your windows administrator to enable a firewall exception for WINRM. WINRM is the thing that PowerShell uses it for remoting purposes. So before connecting to remote server it is necessary to ... Read More

How PowerShell Remoting Works

Chirag Nagrekar
Updated on 25-Jul-2020 11:23:32

389 Views

There are several ways to connect to remote computer cmdlets. These computers can be in the same domain, different domains, or for the workgroups using PowerShell. Here, we will mainly focus on the inbuilt parameter, Invoke-Command, and to execute PSSession command remotely.Inbuilt -ComputerName parameter.Many cmdlets in PowerShell supports the -ComputerName parameter, which describes the remote computer names. For example, Get-Service, Get-Process, and Get-WMIObject, etc.. cmdlets.ExampleIf the remote server is in the same domain then you just need to simply add -ComputerName credentials.Get-Service Spooler -ComputerName Test1-Win2k12OutputPS C:\Users\Administrator> Get-Service Spooler -ComputerName Test1-Win2k12 Status            Name         ... Read More

Find Pairs with Given Product in a Sorted Doubly Linked List in C++

Arnab Chakraborty
Updated on 25-Jul-2020 11:12:21

271 Views

ConceptWith respect of a given sorted doubly linked list of positive distinct elements, our taskis to determine pairs in the doubly linked list whose product is equal to given value x, without consuming any extra space.InputList = 1 2 4 5 6 8 9 x = 8Output(1, 8), (2, 4)InputList1 = 1 2 3 4 5 6 7 x = 6Output(1, 4), (2, 3)MethodAccording to a Simple Approach for this problem, we traverse the linked list implementing two nested loops and determine all pairs and verify for the ... Read More

Find Original Numbers from GCD of Every Pair in C++

Arnab Chakraborty
Updated on 25-Jul-2020 10:55:18

350 Views

ConceptWith respect of a given array array[] containing GCD of every possible pair of elements of another array, our task is to determine the original numbers which are used to compute the GCD array.Inputarray[] = {6, 1, 1, 13}Output13 6 gcd(13, 13) = 13 gcd(13, 6) = 1 gcd(6, 13) = 1 gcd(6, 6) = 6Inputarr[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 6, 6, 8, 11, 13, 3, 3}Output13 11 8 6 6MethodAt first, sort the array in decreasing order.Largest element will always be one of the ... Read More

Find Number of Edges to Break in a Tree for Equal Bitwise OR in C++

Arnab Chakraborty
Updated on 25-Jul-2020 10:51:58

306 Views

ConceptWith respect of a given tree with m nodes and a number associated with every node, we canbreak any tree edge which will result in the formation of 2 new trees. Here, we have to count the number of edges in this way so that the Bitwise OR of the nodes present in the two trees constructed after breaking that edge are equal. It should be noted that the value ofevery node is ≤ 10^6.Inputvalues[]={1, 3, 1, 3}      1    / | \   2 3 4Output2Here, the edge between 1 and 2 can be broken, the Bitwise ... Read More

Find Nth Term of a Given Recurrence Relation in C++

Arnab Chakraborty
Updated on 25-Jul-2020 10:45:38

246 Views

ConceptAssume bn be a sequence of numbers, which is denoted by the recurrence relation b1=1 and bn+1/bn=2n. Our task is to determine the value of log2(bn) for a given n.Input6Output15Explanationlog2(bn) = (n * (n - 1)) / 2 = (6*(6-1))/2 = 15Input200Output19900Methodbn+1/bn = 2nbn/bn-1 = 2n-1...b2/b1 = 21, We multiply all of above in order to attain(bn+1/bn).(bn/n-1)……(b2/b1) = 2n + (n-1)+……….+1So, bn+1/b1 = 2n(n+1)/2Because we know, 1 + 2 + 3 + ………. + (n-1) + n = n(n+1)/2So, bn+1 = 2n(n+1)/2 . b1; Assume the initial value b1 = 1So, bn+1 = 2sup>n(n+1)/2Now substituting (n+1) for n, we get, ... Read More

Find N Distinct Numbers Whose Bitwise OR is Equal to K in C++

Arnab Chakraborty
Updated on 25-Jul-2020 10:36:52

267 Views

ConceptWith respect of given two integers N and K, our task is to determine N distinct integers whose bitwise OR is equal to K. It has been seen that if there does not exist any possible answer then print -1.InputN = 4, K = 6Output6 0 1 2InputN = 11, K = 6Output-1It is not possible to find any solution.MethodWe have knowledge that if bit-wise OR of a sequence of numbers is K then all the bit indexes which are 0 in K must also be zero in all the numbers.As a result of this, we only have those positions ... Read More

Find Missing Element in a Sorted Array of Consecutive Numbers in C++

Arnab Chakraborty
Updated on 25-Jul-2020 09:38:44

447 Views

ConceptWith respect of a given array array[] of n distinct integers, elements are placed sequentially in ascending order with one missing element. Our task is to determine the missing element.Inputarray[] = {1, 2, 3, 4, 5, 6, 7, 9}Output8Inputarray[] = {-4, -2, -1, 0, 1, 2}Output-3Inputarray[] = {1, 2, 3, 4}Output-1No element is missing.MethodPrinciplesLook for inconsistency: According to this principle, the difference between any element and its index must be array[0] for every element.Example, A[] = {1, 2, 3, 4, 5} -> ConsistentB[] = {201, 202, 203, 204} -> ConsistentC[] = {1, 2, 3, 5, 6} -> Inconsistent as C[3] ... Read More

Find Minimum Time to Finish All Jobs with Given Constraints in C++

Arnab Chakraborty
Updated on 25-Jul-2020 09:34:02

414 Views

ConceptWith respect of a given array of jobs with different time requirements, there exists k identical assignees available and we are also provided how much time an assignee consumesto do one unit of the job. Our task is to determine the minimum time to complete all jobs with following constraints.The first constraint is that an assignee can be assigned only contiguous jobs.Here, for example, an assignee can be assigned jobs at position 1 and 2, but not at position 3, in an array.The second constraint is that two assignees cannot share (or co-assigned) a job, that means, a job cannot ... Read More

Find Minimum Adjustment Cost of an Array in C++

Arnab Chakraborty
Updated on 25-Jul-2020 09:22:58

421 Views

ConceptWith respect of a given array of positive integers, we replace each element in the array so that the difference between adjacent elements in the array is either less than or equal to a given target. Now, our task to minimize the adjustment cost, that is the sum of differences between new and old values. So, we basically need to minimize Σ|A[i] – Anew[i]| where 0 ≤ i ≤ n-1, n is denoted as size of A[] and Anew[] is denoted as the array with adjacent difference less than or equal to target. Let all elements of the array is ... Read More

Advertisements