728x90

$Searcher = New-Object -ComObject Microsoft.Update.Searcher
$SearchResult = $Searcher.Search($Criteria).Updates
$SearchResult.count

 

 

결과

PS C:\Users\iadmin> $Searcher = New-Object -ComObject Microsoft.Update.Searcher

PS C:\Users\iadmin> $SearchResult = $Searcher.Search($Criteria).Updates

PS C:\Users\iadmin> $SearchResult.count

0

PS C:\Users\iadmin>

728x90
728x90

ClientNetworkProtocol Client 의 네트워크 접속 프로토콜의 정의와 우선순위를 결정하는 클래스입니다.

지난번과 같이 WMIObject ClientNetworkProtocol 클래스를 가져와 볼까요

Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocol | Select-Object ProtocolName, ProtocolDisplayName, ProtocolOrder




저 같은 경우 로컬에 SQL이 깔려있기 때문에 우선순위 첫번째가 메모리로 나오네요
원격인 경우 TCP 1 로 보입니다. 참고로 ProtocolOrder 0은 비사용중임을 나타냅니다.

 


이 클래스의 메소드들은..

Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocol |
Get-Member -memberType Method | Select-Object Name

 


이와 같이 프로토콜의 사용여부와 우선순위를 설정하는 메소드들입니다.



위에 메소드를 이용한 아래의 간단한 스크립트는 Named Pipes 를 비사용으로 바꾸는 역할을 합니다.

$WClientNetProtol=Get-WmiObject –namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocol -filter "ProtocolName='np'"
$WClientNetProtol.SetDisable()



Named Pipes가 비사용중으로 바뀌었네요



ClientNetworkProtocol의 속성 변경을 원할 경우 ClientNetworkProtocolProperty 클래스를 이용하시면 됩니다.

살짝 살펴보면 ..

Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class

ClientNetworkProtocolProperty | Select-Object PropertyName, PropertyNumVal, PropertyStrVal,ProtocolName

 


기본접속 포트가 1433으로 설정되어 있네요


아래는 TCP/IP 프로토콜의 기본접속 포트를 1433에서 15886로 변경하는 스크립트입니다.

$WClientNetProto=Get-WmiObject –namespace root\Microsoft\SqlServer\ComputerManagement10 –class
ClientNetworkProtocolProperty -filter "PropertyName='Default Port'"

$ WClientNetProto.SetNumericalValue(15886)


참고: SQL Server Administration with Windows PowerShell

원본: http://vstarmanv.tistory.com/entry/MSSQLWMI-for-SQL-Management2

728x90
728x90

PowerShell 을 이용해서 대량의 파일을 대상으로 내부 내용을 변경 하는 방법을 찾아 보았습니다.

PowerShell 에는 -replace 연산자가 존재하는데, 마치 리눅스의 sed 명령어 처럼 쓸 수 있습니다.

"wow nice olleh" | %{$_ -Replace ("nice","OLLEH")}

 




이 연산자를 사용해서 대량의 파일을 대상으로 내용을 변경 하는 것도 가능 한데요, 아래의 구조로 된 폴더를 예로 들겠습니다.



폴더의 내부에 존재하는 각 파일의 내용에는 nice 라는 문자열이 존재합니다.



만약, "MyDocument" 디렉터리및 하위 디렉터리의 모든 *.txt 파일을 대상으로 파일 내용 중 "nice" 를 "OLLEH" 라고 바꾸고 싶다면, 아래 명령어를 사용하면 됩니다.

dir -Path MyDocument -Include *.txt -Recurse | %{$tmp = Get-Content $_; $tmp=$tmp -Replace ("nice","OLLEH"); Set-Content $_ $tmp}

 


파일의 내용 중 nice 가 모두 OLLEH 로 변경 된 것을 확인 할 수 있습니다.

대량 변경 작업시에 유용하게 사용 할 수 있을 것 같네요. ^^



<참고 URL>
http://www.myitforum.com/articles/40/view.asp?id=11843
http://blogs.msdn.com/b/zainnab/archive/2007/07/09/grep-and-sed-with-powershell.aspx

<참고 도움말>
about_Comparison_Operators

감사합니다.

출처: https://svrstudy.tistory.com/81?category=352377 [Windows Server 공부방]

728x90
728x90

$sqlConnection = New-Object system.data.sqlclient.sqlconnection "server=서버명또는IP;database=DatabaseName;user=계정;비밀번호;trusted_connection=true"
$sqlConnection.Open()
$sqlCommand = $sqlConnection.CreateCommand()
$sqlCommand.CommandText = "Select ResourceId, UserAtHost cnt FROM Resource"
$sqlReader = $sqlCommand.ExecuteReader()
while($sqlReader.Read())
{
$sqlReader["ResourceId"]
$sqlReader["UserAtHost"]
}
$sqlConnection.Close()

728x90
728x90
728x90
728x90

https://gallery.technet.microsoft.com/office/Skype-for-Business-SIP-4d16a292

https://gallery.technet.microsoft.com/office/Skype-for-Business-SIP-4d16a292/file/150771/3/Modality_SIP_Media_Call_Flows.pdf

http://blog.schertz.name/2014/08/understanding-lync-modalities/

https://docs.microsoft.com/en-us/lyncserver/lync-server-2013-network-bandwidth-requirements-for-media-traffic

This guide provides a comprehensive SFB SIP, Media and various PSTN call flows while users  on-premise, Online,  Hybrid, on mobile  or  Internet.

Detail SFB SIP, Media  and  PSTN call flows covering many scenarios on how the calll flows are discovered, started, and established.

This guide will explain and help you understand how SIP, Media and call flow are started , and how  they  discover, reach out  and established communication between two  end-points regardless of  whereever the endpoints are residing.  

 

SFB User registration Scenarios:

1.SFB on-premise user registration with SFB on-premise server while he is  on-premise local network.

2.SFB On-premise user registration with SFP on-premise server while he is on public Internet.

3. SFB Online user registration with Online SFB server while he is on on-premise local network.

4. SFB Online user  registration with Online SFB server while he is on public Internet.

 

SIP and Media Call flows Scenarios:

On-Premise SFB with PSTN Gateway

1. Unified communication between on-premise uses located in the same LAN.

2. Unified communication between user located in the LAN and Internet.

3. Unified  communication between both users  located on the Internet.



Hybrid - Online SFB and On-premise SFB with PSTN Gateway

1. Unified communication between on-premise homed user and SFB Online homed user located in the same LAN.

2. Unified communication between on-premise homed user located in the LAN while SFB Online user on the Internet.

3. Unified communication between SFB Online homed user located in the local LAN while On-premise homed  user on the Internet.

4. Unified communication between when both SFB Online user and SFB on-premise user are on the Internet.

5. Unified communication between both SFB Online users are on the Internet.

6. Unified communication between  SFB online user is in local network  while another SFB online user is on the Internet.

7. PSTN incoming call to on-premise SFB user

8. PSTN incoming call to Online SFB user.

8. PSTN outgoinng call from oo-premise SFB user

9. PSTN outgoing call from Online SFB user.

728x90
728x90

When I am attempting to investigate a setup-related failure, I typically end up looking at verbose log files.  These log files can contain information about a wide variety of failures, and the failures will typically include some detailed error information (such as the information reported by the GetLastError and FormatMessage APIs or something equivalent to them).  In the case of verbose Windows Installer log files, I find the error information in most cases by searching for the text "return value 3" as described in this blog post.

Once I find the error information, I can often recognize the error codes from my past experience.  However, there are also a lot of cases where I run into error codes that I do not recognize from past experience.  When that happens, I use a tool that helps me translate error codes (normally HRESULT values from function calls) into more readable information.  Doing this can help me better understand what the error means, which in turn can help give ideas for what might be causing the error and what types of fixes might help eliminate the error.

Recently, I discovered that the tool that I've been using to do error code translation is available on the Microsoft Download Center so that anyone can get a copy and use it themselves.  You can find the tool, called Err.exe, at http://www.microsoft.com/downloads/details.aspx?familyid=be596899-7bb8-4208-b7fc-09e02a13696c.  This site describes the tool as an Exchange Server Error Code Look-up, but this tool actually aggregates information from 172 sources (header files, etc) from Windows and various other products around Microsoft and is not only useful for Exchange Server issues.

For example, it includes information from corerror.h (a header file that ships with the .NET Framework SDK and Windows SDK) so it can report error information for some types of .NET Framework errors.  Here are a couple of specific examples of the output produced by err.exe:

For error code 0x8002802F (described in more detail here):

Err.exe 0x8002802F
# for hex 0x8002802f / decimal -2147319761 :
  TYPE_E_DLLFUNCTIONNOTFOUND                                    winerror.h
# Function not defined in specified DLL.
# 1 matches found for "0x8002802F"

For error code 0x80070005 (described in more detail here):

Err.exe 0x80070005
# for hex 0x80070005 / decimal -2147024891 :
  COR_E_UNAUTHORIZEDACCESS                                      corerror.h
# MessageText:
# Access is denied.
  DIERR_OTHERAPPHASPRIO                                         dinput.h
  DIERR_READONLY                                                dinput.h
  DIERR_HANDLEEXISTS                                            dinput.h
  DSERR_ACCESSDENIED                                            dsound.h
  ecAccessDenied                                                ec.h
  ecPropSecurityViolation                                       ec.h
  MAPI_E_NO_ACCESS                                              mapicode.h
  STIERR_READONLY                                               stierr.h
  STIERR_NOTINITIALIZED                                         stierr.h
  E_ACCESSDENIED                                                winerror.h
# General access denied error
# 11 matches found for "0x80070005"

In some cases, as shown above for error code 0x80070005, the same error code can map to different meanings in different header files.  In those cases, it is sometimes necessary to make an educated guess about which one is the actual error code being generated by a setup error.  For example, in most cases, if an error code from winerror.h is listed in the output from err.exe, that one is the actual error code.

It is important to note that Err.exe is not intended to be a diagnostic tool on its own.  In other words, it will not be able to tell you how to fix a problem just based on what the error code is.  However, in my experience, Err.exe is very useful as a step along the path of attempting to solve a problem because it provides additional information about what an error code means.  Once you have a better idea about what an error code means, you can often use this additional information to perform some additional Web searches to learn about possible causes of and workarounds for specific types of errors.

 

 

https://blogs.msdn.microsoft.com/astebner/2008/06/17/information-about-the-err-exe-tool-i-use-to-look-up-error-codes-when-debugging-setup-issues/

 

오류코드참조

https://mani4u.tistory.com/24

728x90
728x90

Lately, I have found myself in situations where I don’t have full domain admin rights while working on Lync. This isn’t a bad thing but one area that I consistently run into issues with is the Lync Management Shell. If you are on a Lync Front-end and you don’t have Administrator rights, the local Lync Management Shell doesn’t actually do Role Based Access Control (RBAC). Therefore, I’ll try to execute a command (say, set-csuser, grant-csdialplan, etc) and get a permission denied. Yet, I can go into the Lync Control Panel and change a setting on the user just fine.

The way around this is remote PowerShell. Since I work on many different clients, I wrote a nice little script that will prompt me for my credentials and the remote server or pool.

 

############################################
# Connect-LyncRemotePoSH.ps1
# Written By: Adam Ball
# Version History:
# 1.0 - 12/12/2013 - Initial Script
#
############################################

#You can pass a server or pool name with the script (i.e. .\Connect-LyncRemotePoSH.ps1 myserver.mydomain.com )
param ($poolname)

#If no server or pool was passed when the script executed, pop up a box and ask for it.
if ($poolname -eq $null){
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$poolname = [Microsoft.VisualBasic.Interaction]::InputBox("Enter a Pool or Server to connect to", "Remote Lync Pool or Server", "")
}

#Change the server or pool name in to a properly constructed URL
$poolname = "https://" + $poolname + "/OcsPowershell"
$cred = Get-Credential
$session = New-PSSession -ConnectionURI $poolname -Credential $cred
Import-PsSession $session

 

To execute, simply run the script (assuming proper execution policy is set). It will pop-up a box and ask you for the remote server or pool then pop up another box and ask for your credentials. You can also pass the server or pool name to it as part of the script execution (i.e. “.\Connect-LyncRemotePoSH.ps1 mypool.mydomain.com”).

This is also a nice way for being able to do Lync Management from your desktop without having the Lync tools installed.

Just remember, when you are done, remove the session by running “Remove-PsSession $session”.

FYI

https://phyler.wordpress.com/2013/12/12/lync-and-remote-powershell/

https://support.4it.com.au/article/files-cannot-be-loaded-because-running-scripts-is-disabled-on-this-system/

http://blog.insidelync.com/2011/08/remote-lync-powershell-administration/

 

Since you're using a third party firewall im assuming the native firewall is disabled? In any case double check your firewall rules to ensure 5895 and 5986 (if using ssl) inbound are allowed from your ip, on any port.

 

1. 방화벽 상태 확
   opened ports 80, 135, 443, 445, 5985, and 5986, but I am still unable to connect to the remote machine with the firewall enabled.

2. FE 서버와 파워셀을 날릴 서버에서 파워쉘 Policy "RemoteSigned" 설정
get-ExecutionPolicy RemoteSigned

$credential = get-credential
$sessionoption = new-pssessionoption -SkipRevocationCheck -SkipCAcheck -skipCNcheck
$session = New-PSSession -ConnectionUri https://pool01.mani4u.com/ocspowershell -credential $credential -SessionOption $sessionoption
IMport-Pssession $session

 

728x90
728x90

SELECT @@VERSION


SELECT
      SERVERPROPERTY('ProductVersion') AS ProductVersion,
      SERVERPROPERTY('ProductLevel') AS ProductLevel,
      SERVERPROPERTY('Edition') AS Edition,
      SERVERPROPERTY('ISClusterd') AS Clusterd;
  GO

  SP_READERRORLOG

  HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server\Instance Names

728x90
728x90

 

데이터베이스 위치 변경하는 방법

 

1. 주 데이터베이스 파일이 어떤 것인지 Enterprise Manager 혹은 sp를 이용하여 확인
해당 SQL 서버의 데이터베이스를 선택하고 등록정보를 봅니다.

예) pubs 데이터베이스 정보 보기

sp_helpdb 'pubs '

C:\MSSQL\Data\pubs.mdf
C:\MSSQL\Data\pubs.ldf


2. Query Manager 에서 다음 명령을 수행 후 pubs DB 분리

sp_detach_db pubs

3. 주 데이터베이스 C 드라이브의 mdf, ldf 파일을 D 드라이브에 원하는 곳으로
copy 합니다. 예제에서는 각각

D:\MSSQL\Data\pubs.mdf
D:\MSSQL\Data\pubs.ldf

에 옮기는 것으로 하겠습니다.

4. 파일 copy 가 끝나면, Query Manager 에서 다음 명령을 수행합니다.

sp_attach_db 'pubs','D:\MSSQL\Data\pubs.mdf','D:\MSSQL\Data\pubs.ldf'

5. Enterprise Manager를 기동하여 아까 1번에서 메모했던 속성과 비교합니다.

 

 

 

alter database 사용시는 아래 사이트 참고

http://hyunki1019.tistory.com/136

 

 

 

728x90

+ Recent posts