Skip to main content

Posts

Showing posts from February, 2016

PowerShell split and join string

How to split a string by space using PowerShell? PowerShell provides an easy way to do it using "split" method in PowerShell. The split method accepts any delimiter; it can be space, dash, comma or other characters as long as it has a pattern on the string. The split method will literally split the string and the output is displayed on a separate line or separated via a line feed. Example: $string = "This is my test string" $split_string_array = $string -split " " $split_string_array Output will be: This is my test string If there is a need to remove the spaces but combine the string in one line, PowerShell also provides the "join" method which basically combine or joins the string in one line. Example: $string = "This is my test string" $split_string_array = $string -split " " $join_string_array = $split_string_array -Join "" Write-Host

Check User SID

To check the SID for a user whose profile is not currently login using WMIC, type:         wmic useraccount where (name="user007")    Replace "user007" with the correct username to get the user SID. The SID will be displayed for that particular user being queried.   This will be useful if the profile for that particular user cannot be loaded or corrupted and need to identify the SID for the corrupt user profile. Editing the registry for corrupt user profiles must edit the correct SID or else multiple issues might occur to the system. To check the SID of a currently login user; just open a command prompt and type:     whoami /user The command above will display the username and SID of the currently login user. To check for FQDN (Fully Qualified Domain Name):    whoami /fqdn The FQDN is useful for System Administrator to check which OU (organizational unit) the user belongs to. To check the UPN (user principal name):   

Cannot FTP in Windows explorer

Windows 7 unable to use FTP in Windows explorer. In Windows 7, Microsoft allows to use explorer to browse FTP sites just like browsing my documents or any regular folders or files in the computer. Browsing FTP using windows explorer will not need to use any browser or FTP client, provided of course you have the right credentials to access the FTP site. Open "Computer", press "Alt key" click on "File" and select "Add Network Location", follow on screen instruction, by clicking next button and enter the FTP site. If some issues will occur a message will be displayed like, "The folder you entered does not appear to be valid. Please choose another." Searching the issue on the Internet for users who had encountered and resolve this dilemma has various resolutions or approaches on how to tackle this issue. What works for me when I face this problem was to export registry settings from a working PC to the othe

Change windows service startup type via command line

To change windows service startup type, can easily be done via the graphical interface or GUI. And it's quite convenient doing via GUI if it is one or two computers. If the settings have to be done on multiple computers then it's not efficient to do it via GUI and quite a hassle also since the user has to stop from his/her work. To do things efficiently and save time, it’s better to make changes via command line. To change startup type via command line on multiple servers or remote computers can easily be done using the "SC" command line program. Example below shows how to change start up type service. SC \\Remote_PC config start= option_type Option Type is: Disabled, Delayed-Auto, Auto, Manual The space after start= C:\>SC \\PC007 config MBAMService start= delayed-auto Command above will change MBAMService to Automatic Delayed Start If the command has exectued successfully it will show this message below:

Linux Awk Simple Example

Awk is a programming language included in Linux flavors of OS'es which is typically used for data extraction. Or in a layman term Awk is a utility tool to simplify the life of a lazy and a smart System Administrator when digging out information from a large text file. Often Awk is combined with regexp (regular expression) and also with the side utility tool. That's why, if you search on the internet your search will see some examples that Awk is combined with Sed for more complex searching but with accurate results. Before going on to complex stuff, start with the basic or a simple command to get started. When the complex stuff comes in, with the right or solid foundation it will be easier to understand. But of course, if you find simple stuff is a piece of cake, go ahead and dive in right away to complex stuff. Here's a basic and simple example of Awk. The input is piped or taken from the output of DF -h. df -h | awk '/mnt/ {