Disable Skype ads

2017/03/06

Add to blocked sites the addresses apps.skype.com and g.msn.com.
This can be done through Control Panel settings or through the hosts file.

  • For the first method, go to Control Panel > Network and Internet > Internet Options > Security tab > Restricted Sites > open Sites and add the 2 websites to the list
  • For hosts file method, this file is generally found at C:\Windows\Systems32\drivers\etc ( unless you have a specific Windows folder, in which case try %WINDIR%\system32 ) ; it is usually a hidden folder, so you’ll have to display hidden files in Windows Explorer ( via View options -> Folder Options )
    Add to this file 2 lines with the 2 websites pointing to 0.0.0.0 or 127.0.0.1 (if in doubt, check the examples commented in the hosts file)

One more setting is needed:
Close Skype and then go to Users > [Your Windows Username] > AppData > Roaming > Skype > [Your Skype account name] > config.xml , open the file and search for AdvertPlaceholder , for which you’ll have to change the value of 1 to 0 .

Note 1: Credits go to StackOverflow, IT blogs and alike, sites that helped me with the code when searching for solutions.
Note 2: Be aware that when copy-pasting, the quotes and possibly other characters get messed up by WordPress, you’ll have to replace them.


Deleting folder SymLinks in PowerShell 4 without wiping folder content

2016/06/15

How ?
Use the old CMD for this:

cmd.exe /c rmdir “yourSymLinkFolder”

Note 1: Credits go to StackOverflow, IT blogs and alike, sites that helped me with the code when searching for solutions.
Note 2: Be aware that when copy-pasting, the quotes and possibly other characters get messed up by WordPress, you’ll have to replace them.
Note 3: While I may have tested myself most of the bits of code posted here, please be aware that you’re trying the code/scripts at your own risk, and I take no responsibility for any damage that may occur on your system(s).


Manually install Windows 7 updates

2016/06/09

Download the updates from Microsoft Update Catalog for the desired architecture, x86 or x64, then run from the command line the following:

cd “your/folder/containing/downloaded/updates”
for %h in (*.msu) do start /wait wusa “%cd%\%h” /quiet /norestart

Note 1: Credits go to StackOverflow, IT blogs and alike, sites that helped me with the code when searching for solutions.
Note 2: Be aware that when copy-pasting, the quotes and possibly other characters get messed up by WordPress, you’ll have to replace them.
Note 3: While I may have tested myself most of the bits of code posted here, please be aware that you’re trying the code/scripts at your own risk, and I take no responsibility for any damage that may occur on your system(s).


Check for dangerous certificates on Windows

2016/01/27

Download sigcheck application from Windows Sysinternals and then execute the command

sigcheck -tv

under a command prompt or PowerShell window

More info on How-To Gheek .


Chef recipe for configuring logstash-forwarder on Windows using nssm

2015/11/05

You’ll need to use some third-party tool to properly configure logstash-forwarder as a service on Windows. We decided to use nssm , although the name is not quite the most professional one. There is a nssm Chef cookbook, so this simplified things.
Please let me know if you succeed in simply running the program as a windows service, cause by using sc in PowerShell script embedded in Chef it was just not enough.

Below is the recipe for configuring logstash-forwarder inside a Chef recipe:

install_path = “d:/your_install_path_here”

powershell_script “Stop logstash-forwarder service” do
  code <<-EOH
    Stop-Service logstash-forwarder
  EOH
  only_if “((Get-Service logstash-forwarder) -ne $null) -and ((Get-Service logstash-forwarder).Status -ne ‘Stopped’)”
end

include_recipe ‘nssm’

username = “your_username”
password = “your_password”
domain = “your_domain”

directory install_path do
  recursive true
  action :create
end

remote_file “#{install_path}/logstash-forwarder_windows_386.exe” do
  source ‘ https://download.elastic.co/logstash-forwarder/binaries/logstash-forwarder_windows_386.exe
  atomic_update false
  action :create_if_missing
end

template “#{install_path}/logstash.crt” do
  source ‘logstash.crt.erb’ # certificate file used by logstash server
  atomic_update false
end

template “#{install_path}/logstash-forwarder.conf” do
  source ‘logstash-forwarder.conf.erb’
  atomic_update false
  variables({
    :logstash_cert_path => install_path,
    :logstash_logpath_watch => “the_path_you_want_to_watch”
  })
end

nssm ‘logstash-forwarder’ do
  program “#{install_path}/logstash-forwarder_windows_386.exe”
  args “-config #{install_path}/logstash-forwarder.conf”
  params(
    ObjectName: “#{username}@#{domain} #{password}”
  )
  action :install
end

windows_service “logstash-forwarder” do
  action [:enable, :start]
end

A simplified version of the logstash-forwarder.conf.erb file would look like below:

{
    “network”: {
      “servers”: [ “url.for.logstash.server:5000” ],
      “timeout”: 15,
      “ssl ca”: “<%= @logstash_cert_path %>/logstash.crt”
    },
    “files”: [
      {
        “paths”: [
          “<%= @logstash_logpath_watch %>”
        ]
      }
    ]
}

Of course, don’t forget to specify the usage of the nssm cookbook, inside the metadata.rb file:

depends ‘nssm’

One thing to note though: even with the windows_service resource set with action start, the Windows service for logstash-forwarder starts only on the second converge.
This might be due to the fact that we do a domain join of the VM where the cookbook is executed, and a restart is needed.

Note 1: Credits go to StackOverflow, IT blogs and alike, sites that helped me with the code when searching for solutions.
Note 2: Be aware that when copy-pasting, the quotes and possibly other characters get messed up by WordPress, you’ll have to replace them.


Create network shared folder with permissions using Powershell

2015/10/06

Here it is:

$folderName = ‘c:/temp/shared’
$shareName = ‘NetworkShare’

if (!(Test-Path $folderName))
{
  New-Item $folderName -type Directory
}

if (!(Get-WmiObject Win32_Share -filter “name=’$shareName’”))
{
  $Shares=[WMICLASS]”WIN32_Share”
  $shares.create($folderName, $shareName, 0)
}

#Use shorter name for .Net class
$accessRule = [System.Security.AccessControl.FileSystemAccessRule]

$Acl = Get-Acl $folderName
$Acl.SetAccessRuleProtection($True, $False)
$rule = New-Object $accessRule(‘Administrators’,’FullControl’,’Allow’)
$Acl.AddAccessRule($rule)
$rule = New-Object $accessRule(‘your_domain\your_user’,’FullControl’,’Allow’)
$Acl.AddAccessRule($rule)

Set-Acl $folderName $Acl
(Get-WmiObject Win32_Share -filter “name=’$shareName’”) | Get-Acl | Format-List *

Replace your_domain and your_user with desired username.

Update: Had issues in Chef when trying to filter the shared folders by the one specified by $shareName variable, because the quotes were always removed by the Chef compiler. In this case, try the following:

$sharedDir = ((Get-WmiObject win32_share) | select Name).Name | where { !($_ -eq $null) -and $_.tolower().equals($shareName.ToLower()) }

Note 1: Credits go to StackOverflow, IT blogs and alike, sites that helped me with the code when searching for solutions.
Note 2: Be aware that when copy-pasting, the quotes and possibly other characters get messed up by WordPress, you’ll have to replace them.


Issue when zipping folder with Chef resource windows_zipfile

2015/09/18

If you receive the warning

Single directory must be specified for compression, and [folder] does not meet that criteria.

when trying to zip a file with Chef resource provider windows_zipfile from windows cookbook, well… it just means what it says: the specified folder is not a folder or doesn’t exists.

The reason I’ve spend more than an hour investigating this is because I was using artifact_deploy resource to first download a build, from which I wanted afterwards to zip only a subfolder; and also, there were several cookbook dependencies, which also had to be compiled… so there goes wasted time.

But the problem is that artifact_deploy uses versioning, so I had to add a current subfolder to point to the right location.
Just to be sure you have the right folder specified, do a

Chef::Log.warn(“Source: #{backup_path}/current/#{app_name}/subfolder

in your cookbook, and paste the output into the file manager from the virtual machine used for testing the cookbook.

Note: Chef::Log.info doesn’t work for me on simple kitchen converge (Chef 12.4), that’s why I used the warn method. Of course, on DEBUG, it’s displayed either way.

Hope this helps someone.

Note: Be aware that when copy-pasting, the quotes and possibly other characters get messed up by WordPress, you’ll have to replace them.


%d bloggers like this: