Powershell

Powershell – Get Public IP

Today I write a quick tips đŸ™‚ Sometime, we need to know the external public IP address for a computer using Powershell. This can be done easily with a Web Service of ipify.org.

Powershell Public IP

Powershell Public IP

(Invoke-WebRequest -uri "https://api.ipify.org/").Content

More

You can get more information about ipify.org here

Share
SCCM

Powershell – Execute SCCM 2012 Applications

Sometimes, it can be useful to execute an Application / Package in the SCCM Software Center using Powershell.
For example, if an application is only available, not required, in the deployment and you want to install several package without logging to the computer.

Unfortunately, there is no built-in powershell cmdlet to do this. We must call method with a specific dll.

Continue reading

Share
WindowsServer

Powershell – Create Shared Folder for DFS

When you want to use DFS (Distributed File System), and get benefit of the replication, you have to create a shared folder and install features on each server. It can be time consuming to do this for a lot of server.

To create it quickly, you can create a package on SCCM with a Powershell script, and deploy it to all of your servers.

Create shared Folder for DFS

You can find below a powershell script to execute :

  1. Create a folder.
  2. Share it with a specific group.
  3. Install Windows Features to enable DFS Replication.
New-Item "D:\Share\MyFolder" -type directory
 
New-SMBShare –Name "MyShareName" –Path "D:\Share\MyFolder" -ReadAccess "everyone"
 
Install-WindowsFeature FS-DFS-Replication, RSAT-DFS-Mgmt-Con

You can find more information about DFS : http://technet.microsoft.com/en-us/library/jj127250.aspx

Share
WindowsServer

Powershell – How to disable NetBios

Disable Netbios

If you want to use Powershell to disable Netbios on several computers, you can execute this script:

$adapters=(gwmi win32_networkadapterconfiguration )
Foreach ($adapter in $adapters){
  Write-Host $adapter
  $adapter.settcpipnetbios(2)
}

Options

Parameters for settcpipnetbios are:

  • 0: Enable Netbios via DHCP.
  • 1: Enable Netbios on the interface.
  • 2: Disable Netbios on the interface.

For more information on this function: http://msdn.microsoft.com/en-us/library/aa393601(v=vs.85).aspx

Verification

After the script was runned, you will have this configuration:
Disable netbios

Share