≡ Menu

Hide Acrobat Reader Tool bar in Mac/Windows

Side bar(Tool bar) that appears with Adobe Acrobat Reader with options like Export PDF, Create PDF, Edit PDF, etc, is frustrating sometimes as you don’t find a way to close/minimise it. When reading any PDF files, it is taking at least 30% of the screen space.

Acrobat Reader RC disable Tool pane

There is an option to disable this tools pane but it is not working as expected. If you want you can try it as well by following the below instructions.

  1. Go to Edit > Preferences (or press Ctrl+K in Windows and Command+K in Mac)
  2. Go inside “Documents” section
  3. uncheck “Open tools pane for each document”.

There are some forums which are advising to edit a XML file to get rid of this tool bar pane, but for a normal user they are little complex.

One quick and easy way that I came across is a key combination. See below based on your operating system.

Windows : SHIFT + F4

MAC : SHIFT+Fn+F4

Pressing above key combination toggles the tool bar pane in acrobat reader. So you can easily enable or disable as you need.

{ 0 comments }

PowerShell: How to query date time without seconds

How many times you got a need for querying the date time variable using Get-Date or [DateTime]:Now but without seconds value in it or making it as 00 seconds? Let us find out what are the options to achieve this using PowerShell.

By default Get-Date cmdlet gives seconds as well. In some cases we feel reading till minutes is sufficient or we want to round off to 00 seconds. This is possible if you decide to convert time value to a string as shown below.

$datetime = Get-Date -Format “yyyyMMddHHmm”

[datetime]::ParseExact($datetime,“yyyyMMddHHmm”,$null)

While this is good, I was looking for better approaches to do this without actually converting it to a string. Lucky I came across one.

This approach is simple which deducts seconds from current date time value to make it zero.

$datetime = Get-Date

$datetime.AddSeconds($datetime.Second)

date-time-without-seconds

Hope you liked it.

{ 0 comments }

How do we know if a variable of type [DateTime] is in UTC or Local time zone? Let us see how to achieve this using PowerShell.

First you need to ensure that date time information is stored in proper DateTime variable. To check you can invoke GetType() method on the variable that is containing the date time information and it tells us whether it is of date time type or not.

$Date = Get-Date

$Date.GetType()

get-date-time-type

 

Once it is confirmed then you can check if the time in the variable is a local time or in UTC timezone by reading the Kind property value. This property has 3 possible values.

  1. Local : The time represented is local time.
  2. UTC : The time represented is UTC.
  3. Unspecified: The time represented is not specified as either local time or Coordinated Universal Time (UTC).

Let us see a quick example:

$Date = Get-Date

$Date.Kind

$UTCDate = $Date.ToUniversalTime()

$UTCDate.kind

A sample screenshot of output is below:

date-time-kind

Hope you liked it. Do you know how to find the exact time zone of a date time variable? I will come up with another post for it.

{ 0 comments }

There are several complains around internet that browser links(especially from Google search results) are not working after upgrading iOS to 9.3. This is noticed on my iPhone today with following symptoms.

Problem

  1. Right click on results from Google search results in Safari browser not working and hanging the Safari browser
  2. Selecting a link in Google search results not working. The page is not going anywhere.
  3. Same problem is noticed with Google Chrome on iPhone
  4. I have not tested with firefox but there are people complaining similar things with it in forums

If you are also facing similar issues and looking for a fix, then you might want to try disabling Java scripts in Safari browser. This worked for me. One thing I noticed is the richness of google search is lost after disabling the Java scripts. This seems expected since Google runs a lot of Java scripts to provide better user experience.

Solution

  • Go to Settings
  • Scroll down to Safari and select it

Safari Advanced Settings

  • Again scroll down till you see Advanced and select it

 

Safari Settings

  • Now slide the bar again Java Scripts to disable the functionality.

Settings

Hope this helps. From the threads in Apple forums I read that Apple is aware of this problem and working on addressing it. Till they come up with a fix, you may want to start using above work around.

Do you know any other better solution or tips for making links in Google search work for Safari browser? Please write in comments section, I am happy to append here.

{ 0 comments }

How to cancel Netflix India subscription

A bit out of topic for this blog, but useful for people who look for unsubscribe option like me. Last month I subscribed to Netflix subscription in INDIA with an excitement But after a month I decided to end the subscription due to some reasons. Personally, I am very happy to see Netflix in INDIA with access to lot of US based movies and TV shows. I am looking forward to see more content coming in.

Initially I was not clear how to unsubscribe. After exploring a bit, I found the easy way.

You just need to visit https://www.netflix.com/CancelPlan and login with your Netflix account. And then you will see a Finish cancellation button like shown in the picture. Click on it and you will see a confirmation message.

NetFlix-unsubscribe-india

The message is clear that my subscription will be active for the current billing cycle as I already paid for it. You can visit http://gadgets.ndtv.com/internet/features/how-to-cancel-your-netflix-subscription-797974 for more options to unsubscribe from Netflix.

{ 2 comments }

C# typeof equivalent in PowerShell

Those who are good with C# knows what typeof does. Basically is used for finding the type data of a given variable or object. How do we do this when it comes to PowerShell? Is there any equivalent keyword for typeof in PowerShell? Let us find out.

PowerShell implements typeof in little different way. Instead of using the typeof keyword like in C#, the PowerShell provides a method called GetType() for each variable or object to find its type. For example, if you want to find data type of a variable called $username, you can know it by calling $username.gettype().

$username = “techibee”

$username.GetType()

PowerShell Typeof equivalent

You can also check if the returned type is a string, integer or some other data type by comparing it as shown below.

$username = “techibee”

$username.GetType() -eq [string]

$age = 12

$age.GetType() -eq [int32]

$age.GetType() -eq [string]

PowerShell typeof

Do you know any other case where PowerShell’s Gettype() cannot replace typeof keyword in C#? Please post in comments section.

{ 0 comments }

With the increase in use of Windows 10 operating system, you may want to find out how many Windows 10 computers are currently added to your Active Directory Domain. This code snippet will help you to query this information and export it to excel or CSV.

Get-ADComputer cmdlet in ActiveDirectory module is used for querying Computer account details and we can use it to query Windows 10 installations as well. It queries all computers that containing any version of Windows 10 Operating system.

Import-Module ActiveDirectory

Get-ADComputer -Filter { OperatingSystem -like “Windows 10*” } -Properties OperatingSystem

This code needs ActiveDirectory PowerShell  module. You can also try exporting it to CSV by piping the output to Export-CSV cmdlet.

Import-Module ActiveDirectory

Get-ADComputer -Filter { OperatingSystem -like “Windows 10*” } -Properties OperatingSystem | Export-Csv c:\temp\windows10comps.csv -NoTypeInformation

You will see the output recorded in c:\temp\windows10comps.csv file.

{ 0 comments }

Reversing a array using PowerShell

Array is a collection of items. Sometimes we needed to reverse or inverse a array collection. There are many approaches available in PowerShell for doing the reverse or inverse operations but the approach talked in this article is most easiest one.

Reversing String Array using PowerShell

The [Array] accelerator in PowerShell has a static method called reverse() which can be used to reverse a array. This method really doesn’t distinguish whether it is string array, number array or any other kind of array. All it does is reversing it. Though array type is not a matter, I have given a examples for each array type below for better understanding.

$StringArray = @(“abc”,“xyz”,“thn”)

$StringArray

[array]::Reverse($StringArray)

$StringArray

Reversing String Array

Reversing String Array

Reversing numeric array using PowerShell

Below is a example for reversing a numeric array using PowerShell.

$numbericarray = @(1,2,4,3,6,9,7)

$numbericarray

[array]::Reverse($numbericarray)

$numbericarray

Reversing Numeric array

Reversing Numeric array

Reversing Characters array using PowerShell

Below example is for reversing a characters array. Approach is similar to reversing number or string based arrays.

$chararray = @(‘a’,‘c’,‘g’,‘d’,‘r’)

$chararray

[array]::Reverse($chararray)

$chararray

 

Reversing Char array

Reversing Char array

Hope this article helps.

 

 

{ 0 comments }

PowerShell -eq, -ceq and -ieq Comparison Operators

This article helps you in understanding -eq, -ceq, -ieq Comparison operators in Windows PowerShell which is used for comparison purpose. The usage examples of PowerShell -eq operator in this article gives a better understanding of its usage.

Summary

Windows PowerShell is one of the great shells that Microsoft ever designed & developed. With help of PowerShell Windows Administrators and developers are benefited a lot as it simplifies the automation in Windows Operating System. You can read more about PowerShell and its uses from TechNet site.

Since the scope of this article is to know more about PowerShell -eq operator, let us start looking at it.

The comparison operator (-eq):

PowerShell is like any other programming language. While developing scripts using PowerShell we need to make use of operators. The -eq (called as equal) operator is one of them. As the name indicates the purpose of this -eq operator is to perform comparison in PowerShell. We can compare strings, numbers and characters using -eq operator. This operator is used for comparing scalar values. The output this -eq operator is a Boolean value(True or False) which indicates whether the input scalar values are equal or not.

Examples:

Now let us look at some examples to understand how to use this -eq operator in Windows PowerShell for comparison purpose.

String Comparison:

Two strings can be compared using -eq operator in PowerShell to verify if they are equal or not.

“abc” -eq “abc”

“abc” -eq “xyz”

string-comparison-1

The above code is comparing one string with another and returning True or False based on whether strings are equal or not. You will have to do this many times while writing PowerShell scripts based on your requirements.

Look at the below example where PowerShell -eq operator is used to determine if the user has entered correct PIN number or not.

$UserPIN = Read-Host “Enter your Name”

if($UserPIN -eq “Steve”) {

Write-Host “Welcome Steve!!”

} else {

Write-Host “Sorry $UserPIN, only Steve is allowed”

}

String-Comparision-2

This -eq operator in PowerShell can accept collections type of variables as well but the use cases of it are less and I don’t want to create confusion by discussing it here.

 Numeric Comparison:

Like the way the -eq operator used for string comparison, it can compare number values as well. Look at the below examples.

100 -eq 100

100 -eq 110

0100 -eq 100

10.1 -eq 10.1

10.2 -eq 10.1

numeric-comparison-1

It compared both the operands passed to it and returned the result. You might wonder how it knows if the operands passed to -eq operator are strings or numeric values. That is the beauty of PowerShell. It is capable of understanding the variable type and then perform the comparison.

Also you might have noticed that -eq is capable of comparing decimal number as well.

Character Comparison:

Character comparison in PowerShell is similar to String or numeric comparison. You can compare two characters using -eq operator to verify if they are equal or not.

‘c’ -eq ‘c’

‘c’ -eq ‘z’

See above example for character comparison. If both characters are equal then it returns True otherwise False.

character-comparison-1

Case-sensitive and Case-insensitive Comparison:

So far all the examples we have seen above are case-insensitive comparisons. Yes, PowerShell -eq operator is designed to perform case insensitive comparison operators. But your PowerShell script requirements might need case sensitive comparisons as well for exact string comparison.

To address such needs, PowerShell has two more operators for string comparison.

  1. Case-Sensitive Comparison (-ceq)
  2. Case-Insensitive Comparison (-ieq)

Case-Sensitive Comparison (-ceq):

This operator works similar to -eq operator but returns false if the strings being compared are different by case. For example, it returns false when you try to compare Windows with windows. Because the first term is having W in capital.

See below example to see how it works:

“Windows” -eq “windows”

“Windows” -ceq “windows”

case-sensitive-compare

Case-Insensitive comparison (-ieq):

Even though the -eq operator performs string comparison in case-insensitive way, you still want to ensure a case insensitive comparison, you can use -ieq. The usage of this parameter is very less because most people use -eq which does the same thing. If you know any case where -ieq is preferred over the -eq, please post in the comments of this article so that I will get it added here.

Below is a small example that shows the case-insensitive comparison of strings.

“linux” -eq “Linux”

“linux” -ieq “Linux”

“linux” -ceq “Linux”

case-insensitive-compare

The case insensitive compare(-ieq) and the regular compare operator(-eq) returned True in both the cases. But the case sensitive(-ceq) compare returned False.

This case insensitive or sensitive kind of operators are applicable only for Strings and Characters. The numeric values don’t have any case so using -eq operator alone is sufficient.

Do you have any questions about using any of these -eq, -ceq, or -ieq operators? Feel free to post it in comments section below this article.

{ 0 comments }

Get SID of a User account using PowerShell

System administrators want to find SID of user account for troubleshooting purpose and other requirement. In this post let us see how to resolve a user account to SID using PowerShell.

PsGetSid is one of the favorite utility for Windows Server administrators for resolving user names to SID. There are otherways to do this as well. One of the ways is using System.Security.Principal namespace. The script below is based on the classes in this name space. You can check this TechNet page to understand more about its usage using PowerShell.

Save the below code as Get-UserSID.ps1 and then it is ready for usage. Look at the below usage examples.

[CmdletBinding()]            
Param(            
    [Alias("User","UserName","Identity")]            
    [string[]]$UserAccount,            
    [string]$DomainName = $env:USERDOMAIN            
)            
            
foreach($User in $UserAccount) {            
 $object = New-Object –TypeName PSObject –Prop (            
                @{'UserName'=$null;            
                'DomainName'=$null;            
                'SIDValue'=$null}            
                )            
            
 $Object.UserName = $User.ToUpper()            
 $Object.DomainName = $DomainName.ToUpper()            
 try {            
     $UserObject = [System.Security.Principal.NTAccount]::new($DomainName,$User)            
     $out = $UserObject.Translate([System.Security.Principal.SecurityIdentifier])            
  $Object.SIDValue = $out.Value            
             
 } catch {            
  $Object.SIDValue = "FAILED"            
 }            
$Object            
}            

Example#1: Resolve a single user account name to SID

.\Get-UserSID.ps1 -UserAccount testuser21

get-usersid-1

Example#2: Resolve multiple user accounts to get their SIDs

.\Get-UserSID.ps1 -UserAccount testuser21,testuser22

get-usersid-2

Example#3: Get SID of a user account from a domain other than current logged on user domain

.\Get-UserSID.ps1 -UserAccount testuser21,testuser1 -DomainName winops.com

get-usersid-3

This script is a good alternative for psgetsid.exe utility and can be incorporated into any of your scripts to get a user account’s SID details.

Do you have any questions about the usage? Feel free to post it in comments section.

{ 0 comments }