Skip to main content

Posts

Showing posts from June, 2015

PowerShell move files and change file name

PowerShell can easily move files to another folder. Ever want to move files and change the filename or add date tags to the filename? Well, it can be done automatically or manually. Choice is always at the hands of the person doing the task. Manual task is always practical if it is just a few numbers of files. But if the task is repetitive or the files range from hundred to thousand, manual task could be daunting or probably not an option. If the task is repetitive, automation should be a good if it not a best option. If numbers of files are quite large automation is good as well, it saves time and effort. PowerShell is always a friend when it comes to automation and saving time. Here's the PowerShell code to move files without hassle. This code below moves a single file to the folder location specified. ======================= #Get the current date $xdate = Get-Date -UFormat "%Y-%b-%d-%A" #Write-Outpu

Ports Replication Used by Active Directory

If replication is failing between servers in Active Directory, ports below should be checked whether they are open, block or other application is using them. Port           135     RPC-based replication (Dynamic) TCP LDAP       389     UDP / TCP LDAP       636     TCP (SSL) LDAP       3268   (Global Catalog) Kerberos   88       UDP / TCP DNS         53        UDP / TCP From the list of ports the easiest one to troubleshoot is port 53, if replication is failing and at the same time users are complaining that they are not able to access websites using domain names such as facebook, twitter or youtube. Then put DNS as top priority on troubleshooting procedures. One good habit that Sys Ad should have is to take record every little change that has been made on the system. Troubleshooting can be easier if there is a record for every change made. Check out more details on this Technet links below: https://technet.microsoft.com/en-us/library/cc772726(WS.10).aspx#w2k3tr_repu

PowerShell get folder security settings

How to check or get which accounts have the modify rights on a particular folder using PowerShell? If the user account or security group account has modify rights, it means that account or group can delete the file or files on a folder. To list the user accounts or security groups on a folder, a PowerShell scripts can come handy. But of course it can be done via GUI, by right clicking on the folder and clicking on the security tab which will show the list of security accounts and its access settings. The PowerShell code below will get the list of accounts which have modify rights on the folder specified on the script. Here's the code: $folder ="D:\myDFolder" $acl = (Get-Acl $folder).Access   | where {$_.FileSystemRights -eq “Modify, Synchronize”} | select IdentityReference Write-Output $acl It's a three line code but does a very good job. Sample output: IdentityReference                                                                                                  

Find XLSTART path using Excel VBA

Get or find default path for XLSTART. Sub Find_XLSTART() Dim Str_XLSTART As String Str_XLSTART=  Application.StartupPath Msgbox Str_XLSTART End Sub Message box will show the XLSTART path on the computer, copy and paste the path to windows explorer and press enter.

Excel VBA Read Formatted Cell value

In Excel VBA if a particular cell has been formatted to a particular format such as as a custom date format. If the value is being read or retrieve using VBA, VBA might not be able to read the data as expected. Example, Range B2 has been formatted to a custom format as "h:mm AM/PM". Range B2 has a value of 3:08 PM as displayed on excel worksheet. In VBA to retrieve the cell value, code could be: Dim xval as variant xval=range("B2").value msgbox xval Msgbox xval will not display as "3:08 PM", it might be displayed as a decimal value because of the custom formatting set on the cell. To get the value as displayed on the cell, code can be changed as: Dim xval as Variant xval=Range("B2").Text Msgbox xval Msgbox will display the value as seen on the excel worksheet. Cheers..Hope it helps.. ========================= Excel Keyboard shortcuts guide https://pl

Powershell get user info from name

Get user logon name (UPN), SID,OU membership from account name. If you only have name as your info and you want to get other infos such as SID, UPN, OU membership and other details. A correct name should be good enough to get more details from PowerShell. Code below will get this output: - Get user SID - Get user UPN or user logon name - Get user Full Name - Get user OU membership ======================================= #set the user name to be queried $user="Juan Karlos" #code below will display the name and samaccountname #$userinfo = Get-ADUser -Filter "Name -eq '$user'" | Select-Object name, samaccountname #code below will display only the value or the samaccountname without the header #-ExpandProperty will hide the header $userinfo = Get-ADUser -Filter "Name -eq '$user'" | Select-Object  -ExpandProperty samaccountname #Display more details about the user information Get-aduser -Identity $userinfo #Display the output on the consol

Hyper-V VM does not respond to ping

Virtual Machine within the Hyper-V is not responding to ping, firewall could be blocking the response. Open an elevated command prompt, type the command below:    netsh firewall set icmpsetting 8 After typing this try to ping the IP Address of the VM it should respond to ping request. If still doesn't work, make sure no other third party software installed on the VM that could be overriding the windows firewall.