0

Tips & Tricks : Missing SQL Server assmeblies in PowerShell

-

When you try to connect to SQL Server from PowerShell script and you get following message:


Unable to find type [Microsoft.SqlServer.Management.Smo.Server]

then you have to download and install following components:

  • Microsoft System CLR Types for SQL Server 2008 R2
  • Microsoft SQL Server 2008 R2 Shared Management Objects
  • Microsoft Windows PowerShell Extensions for SQL Server 2008 R2

From here.

0

Tips & Tricks : BitLocker requires recovery key when USB device connected at startup

-

Sometimes when you start machine with BitLocker enabled and same time some storage device was connected to USB port, BitLocker might request Recovery Key. This happens because USB ports is listed on boot device search list. To avoid this type of event best idea is to remove USB from boot search list. However, changing list of boot devices might also trigger BitLocker.

How to deal with this type of situation? Follow steps below:

  1. Suspend BitLocker  – command: manage-bde -protectors -disable c:
  2. Reboot machine
  3. Go to BIOS and remove all USB devices from available boot devices list
  4. Boot up to Windows
  5. Resume BitLocker – command: manage-bde -protectors -enable c:
NOTE: All above commands have to be issues from Command Prompt with elevated privileges.

After that no more issues with BitLocker during startup when USB storage devices are connected.

0

Config snippets : Activating Windows Server 2012 Core

-

As there is no GUI in Windows Server 2012 Core, we have to use command line and script in order to acivate system.

slmgr.vbs is a VBscript which allows to set product key and activate operating system. Below most common use of slmgr.vbs.

Set product key

slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX

Activate Windows

slmgr.vbs /ato

Display information about licenses

slmgr.vbs /dli
slmgr.vbs /dlv
0

Code snippets : Enable remote administration on Windows Server 2012 Core

-

By default remote management on Windows Server 2012 Core can be blocked by firewall.

In order to enable this functionality, issue following command from Command Prompt window:


Netsh.exe firewall set service remoteadmin enable ALL

Once it’s done you should be able to manage server remotely.

0

Code snippets : Handy wmic commands

-

Some handy wmic commands which might be helpful when automating OS deployment:

wmic bios get serialnumber
wmic computersystem get manufacturer
wmic computersystem get model
0

Tips & Tricks : CMD Batch parameters

-

Handful list of parameters possible to use in CMD scripts:

%~I         - expands %I removing any surrounding quotes ("")
%~fI        - expands %I to a fully qualified path name
%~dI        - expands %I to a drive letter only
%~pI        - expands %I to a path only
%~nI        - expands %I to a file name only
%~xI        - expands %I to a file extension only
%~sI        - expanded path contains short names only
%~aI        - expands %I to file attributes of file
%~tI        - expands %I to date/time of file
%~zI        - expands %I to size of file
%~$PATH:I   - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string

%~1         - expands %1 removing any surrounding quotes (")
%~f1        - expands %1 to a fully qualified path name
%~d1        - expands %1 to a drive letter only
%~p1        - expands %1 to a path only
%~n1        - expands %1 to a file name only
%~x1        - expands %1 to a file extension only
%~s1        - expanded path contains short names only
%~a1        - expands %1 to file attributes
%~t1        - expands %1 to date/time of file
%~z1        - expands %1 to size of file
%~$PATH:1   - searches the directories listed in the PATH
environment variable and expands %1 to the fully
qualified name of the first one found.  If the
environment variable name is not defined or the
file is not found by the search, then this
modifier expands to the empty string

%~dp1       - expands %1 to a drive letter and path only
%~nx1       - expands %1 to a file name and extension only
%~dp$PATH:1 - searches the directories listed in the PATH
environment variable for %1 and expands to the
drive letter and path of the first one found.
%~ftza1     - expands %1 to a DIR like output line

Very useful for automated software installations for example.