• Check if Object contains property in PowerShell
    31 December

    Check if Object has Property in PowerShell

    Using the -match Parameter Use the -match parameter to check if an object has a property in PowerShell. [crayon-676c16dd69344268819578/] [crayon-676c16dd6934a999655881/] Here, we used the -match parameter to check if the given object, which is $result in our case, has the greetings property. Now, you can refer to this article to learn how the $result object […]

  • Create Empty File in PowerShell
    28 December

    Create Empty File in PowerShell

    Using New-Item Cmdlet Use the New-Item cmdlet to create an empty .txt file in PowerShell. [crayon-676c16dd69738664468862/] [crayon-676c16dd6973c383303531/] We used the New-Item cmdlet with -Path, -Name, and -ItemType parameters to create an empty .txt file using Windows PowerShell. Let’s break down the above command to understand it more clearly. The New-Item cmdlet creates a new item […]

  • 27 December

    Run PowerShell as Another User

    Using the runas Command The runas command in PowerShell launches programs using credentials different from the current user. It provides users with limited privileges to execute commands or access resources available only to more privileged accounts. The command’s syntax is runas /user:UserName ProgramName where UserName is an account with permission and ProgramName is the name […]

  • 27 December

    Create Array of All NaN Values in Python

    Using numpy.empty() Function To create an array of all NaN values in Python: Use numpy.empty() to get an array of the given shape. Assign numpy.nan to every array element using the assignment operator (=). [crayon-676c16dd69a4a965373500/] [crayon-676c16dd69a4d799556141/] We used numpy.empty() to get an array of the given shape and dtype. Here, shape means the number of […]

  • 27 December

    Call Function from Another Function in Python

    1. Introduction In Python, calling a function from another function is a common practice that enhances modularity and reusability. We’ll explore various ways to do this, with complete examples and detailed explanations. Our focus will be on understanding how these methods work, their use cases. As an example, let’s look at a scenario where we […]

  • 27 December

    Return Boolean from Function in JavaScript

    Using the Boolean() Function To get a Boolean from a function in JavaScript: Create a function which returns a Boolean value. Use the Boolean() function to get a Boolean value from the function created in the previous step. [crayon-676c16dd69ef6009248637/] [crayon-676c16dd69efb080689943/] We used the Boolean(), a built-in function in JavaScript, to check if a variable or […]

  • 27 December

    [Fixed] NameError Name ‘unicode’ is Not Defined in Python

    Use str() Method To resolve the NameError: name 'unicode' is not defined, replace the occurrence of unicode() with str(). This issue occurs because unicode() was renamed to str() in Python 3. [crayon-676c16dd6a1b0454186154/] [crayon-676c16dd6a1b4711348275/] Unicode is a computing industry standard that ensures that text from most of the world’s writing systems is consistently encoded, rendered, and […]

  • 26 December

    Concatenate String in PowerShell

    Using Operators To concatenate string in PowerShell: Declare and initialize variables which contain string-type values. Use +, -f, and -join operators to concatenate values of all variables we created in the first step. [crayon-676c16dd6a327142463660/] [crayon-676c16dd6a32c749431604/] We can use the +, -f, and -join operators to concatenate strings with/without separators in PowerShell. Let’s understand the use […]

  • 26 December

    Remove Duplicates from Array in PowerShell

    Using Select-Object with the -Unique Parameter To remove duplicates from array in PowerShell: Use the array operator to create an array having duplicate values. Use the Select-Object with the -Unique parameter to select unique values from the array we created in the previous step. [crayon-676c16dd6a536558538578/] [crayon-676c16dd6a53b085574958/] For this code, we used the array operator (@()) […]