English (UK)

Add-ExchangeAdministrator "MyUser" -role ViewOnlyAdmin

Add-ExchangeAdministrator "MyUser" -role OrgAdmin

Get-MailboxServer MyMailServer | Add-ADPermission -User MyUser
 -AccessRights GenericRead, GenericWrite
 -ExtendedRights Send-As, Receive-As, ms-Exch-Store-Admin

 

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 

objCommand.CommandText = "SELECT SamAccountName FROM 'LDAP://dc=MyDomain,dc=it' WHERE givenName='MyUser'"
Set objRecordSet = objCommand.Execute

If objRecordset.RecordCount = 1 Then
 WScript.Echo "Found"
Else
 WScript.Echo "Not found"
End If
objRecordset.Close

 

/* Quick Transaction */
BEGIN TRAN
 UPDATE myTable SET myField = 'Test' WHERE myId = 1
ROLLBACK TRAN
COMMIT TRAN

/* Extended Transaction */
BEGIN TRANSACTION CandidateDelete
GO
USE AdventureWorks2008R2
GO
UPDATE myTable SET myField = 'Test' WHERE myId = 1
GO
COMMIT TRANSACTION CandidateDelete
GO
ROLLBACK TRANSACTION CandidateDelete
GO

 

$Type = "Error"
$LogFile = "c:\LogFile.txt"
$NewestLogID = 500

Out-File $LogFile

Out-File $LogFile -append -inputobject "      >>@---------------------------@< <"
Out-File $LogFile -append -inputobject "      >>@---   System EventLog   ---@< <"
Out-File $LogFile -append -inputobject "      >>@---------------------------@< <"

$Log = "System"
Get-EventLog -computername MyComputer -logname $Log -newest $NewestLogID | ForEach-Object {
  If ($_.EntryType -eq $Type) {
   Out-File $LogFile -append -inputobject $_.timewritten
   Out-File $LogFile -append -inputobject $_.Source
   Out-File $LogFile -append -inputobject $_.Message
  }
}

Out-File $LogFile -append -inputobject " "
Out-File $LogFile -append -inputobject "      >>@--------------------------------@< <"
Out-File $LogFile -append -inputobject "      >>@---   Application EventLog   ---@< <"
Out-File $LogFile -append -inputobject "      >>@--------------------------------@< <"

$Log = "Application"
Get-EventLog -computername MyComputer -logname $Log -newest $NewestLogID | ForEach-Object {
  If ($_.EntryType -eq $Type) {
   Out-File $LogFile -append -inputobject $_.timewritten
   Out-File $LogFile -append -inputobject $_.Source
   Out-File $LogFile -append -inputobject $_.Message
  }
}

 

[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object Windows.Forms.Form
$form.Text = "My first form"
$button = New-Object Windows.Forms.Button
$button.text="Click here!"
$button.Dock="fill"
$button.add_click({$form.close()})
$form.controls.add($button)
$form.Add_Shown({$form.Activate()})
$form.ShowDialog()