Frequently used Powershell cmdlets

NameAliasDescriptionType
Get-ChildItemdir, gci, lsGets the files and folders in a file system drive.Cmdlet
Invoke-CommandicmRuns commands on local and remote computers.Cmdlet
Import-ModuleipmoAdds modules to the current session.Cmdlet
Export-CsvepcsvConverts objects into a series of comma-separated (CSV) strings and saves the strings in a CSV file.Cmdlet
Write-HostWrites customized output to a host.Cmdlet
Get-WmiObjectgwmiGets instances of WMI classes or information about the available classes.Cmdlet
Get-Contentcat, gc, typeGets the contents of a file.Cmdlet
Get-DateGets the current date and time.Cmdlet
Invoke-WebRequestcurl, iwr, wgetGets content from a web page on the Internet.Cmdlet
Start-Processsaps, startStarts one or more processes on the local computer.Cmdlet
Copy-Itemcopy, cp, cpiCopies an item from one location to another.Cmdlet
Set-ExecutionPolicyChanges the user preference for the Windows PowerShell execution policy.Cmdlet
Out-FileSends output to a file.Cmdlet
Where-Object?, whereSelects objects from a collection based on their property values.Cmdlet
Import-CsvipcsvCreates table-like custom objects from the items in a CSV file.Cmdlet
Send-MailMessageSends an email message.Cmdlet
New-ObjectCreates an instance of a Microsoft .NET Framework or COM object.Cmdlet
Select-StringslsFinds text in strings and files.Cmdlet
Remove-Itemdel, erase, rd, ri, rm, rmdirDeletes files and folders.Cmdlet
Select-ObjectselectSelects objects or object properties.Cmdlet
Test-PathDetermines whether all elements of a file or directory path exist.Cmdlet
Invoke-RestMethodirmSends an HTTP or HTTPS request to a RESTful web service.Cmdlet
Install-PackageInstalls one or more software packages.Cmdlet
ForEach-Object%, foreachPerforms an operation against each item in a collection of input objects.Cmdlet
Write-Outputecho, writeSends the specified objects to the next command in the pipeline. If the command is the last command in thepipeline, the objects are displayed in the console.Cmdlet
Get-Processgps, psGets the processes that are running on the local computer or a remote computer.Cmdlet
Get-ServicegsvGets the services on a local or remote computer.Cmdlet
Format-TableftFormats the output as a table.Cmdlet
Test-ConnectionSends ICMP echo request packets (“pings”) to one or more computers.Cmdlet
New-ItemniCreates a new item.Cmdlet
Get-EventLogGets the events in an event log, or a list of the event logs, on the local or remote computers.Cmdlet
Get-WinEventGets events from event logs and event tracing log files on local and remote computers.Cmdlet
Install-ModuleDownloads one or more modules from an online gallery, and installs them on the local computer.Function
Enter-PSSessionetsnStarts an interactive session with a remote computer.Cmdlet
Get-CredentialGets a credential object based on a user name and password.Cmdlet
Read-HostReads a line of input from the console.Cmdlet
Get-AppxPackageGets a list of the app packages that are installed in a user profile.Cmdlet
Get-AclGets the security descriptor for a resource, such as a file or registry key.Cmdlet
Get-HelpDisplays information about Windows PowerShell commands and concepts.Cmdlet
Start-JobsajbStarts a Windows PowerShell background job.Cmdlet
Add-PSSnapinAdds one or more Windows PowerShell snap-ins to the current session.Cmdlet
New-PSSessionnsnCreates a persistent connection to a local or remote computer.Cmdlet
Invoke-ExpressioniexRuns commands or expressions on the local computer.Cmdlet
Add-ContentacAppends content, such as words or data, to a file.Cmdlet
New-PSDrivemount, ndrCreates temporary and persistent mapped network drives.Cmdlet
Move-Itemmi, move, mvMoves an item from one location to another.Cmdlet
Get-ItemgiGets files and folders.Cmdlet
Compare-Objectcompare, diffCompares two sets of objects.Cmdlet
Sort-ObjectsortSorts objects by property values.Cmdlet
Test-NetConnectionDisplays diagnostic information for a connection.Function
Set-AclChanges the security descriptor of a specified item, such as a file or a registry key.Cmdlet
Set-ContentscReplaces the contents of a file with contents that you specify.Cmdlet
Start-TranscriptCreates a record of all or part of a Windows PowerShell session to a text file.Cmdlet
Get-HotFixGets the hotfixes that have been applied to the local and remote computers.Cmdlet
Get-ItemPropertygpGets the properties of a specified item.Cmdlet
Add-MemberAdds custom properties and methods to an instance of a Windows PowerShell object.Cmdlet
Remove-AppxPackageRemoves an app package from a user account.Cmdlet
Rename-Itemren, rniRenames an item in a Windows PowerShell provider namespace.Cmdlet
Add-TypeAdds a.NET Framework type (a class) to a Windows PowerShell session.Cmdlet
Get-MembergmGets the properties and methods of objects.Cmdlet
ConvertTo-SecureStringConverts encrypted standard strings to secure strings. It can also convert plain text to secure strings. It isused with ConvertFrom-SecureString and Read-Host.Cmdlet
New-SelfSignedCertificateCreates a new self-signed certificate for testing purposes.Cmdlet
Start-SleepsleepSuspends the activity in a script or session for the specified period of time.Cmdlet
Restart-ComputerRestarts (“reboots”) the operating system on local and remote computers.Cmdlet
Out-GridViewogvSends output to an interactive table in a separate window.Cmdlet
Format-ListflFormats the output as a list of properties in which each property appears on a new line.Cmdlet
Set-ItemPropertyspCreates or changes the value of a property of an item.Cmdlet
Measure-ObjectmeasureCalculates the numeric properties of objects, and the characters, words, and lines in string objects, such asfiles of text.Cmdlet
Split-PathReturns the specified part of a path.Cmdlet
Get-CounterGets performance counter data from local and remote computers.Cmdlet
Get-CimInstanceGets the CIM instances of a class from a CIM server.Cmdlet
Add-ComputerAdd the local computer to a domain or workgroup.Cmdlet
Add-AppxPackageAdds a signed app package to a user account.Cmdlet
ConvertTo-HtmlConverts Microsoft .NET Framework objects into HTML that can be displayed in a Web browser.Cmdlet
Import-StartLayoutImports the layout of the Start into a mounted Windows image.Cmdlet
Set-Locationcd, chdir, slSets the current working location to a specified location.Cmdlet
Get-NetAdapterGets the basic network adapter properties.Function
Export-StartLayoutExports the layout of the Start screen.Cmdlet
Enable-PSRemotingConfigures the computer to receive remote commands.Cmdlet
Get-CommandgcmGets all commands.Cmdlet
Get-ExecutionPolicyGets the execution policies for the current session.Cmdlet
Join-PathCombines a path and a child path into a single path.Cmdlet
Import-PSSessionipsnImports commands from another session into the current session.Cmdlet
Get-FileHashComputes the hash value for a file by using a specified hash algorithm.Function
Write-ErrorWrites an object to the error stream.Cmdlet
Stop-ServicespsvStops one or more running services.Cmdlet
Stop-Processkill, sppsStops one or more running processes.Cmdlet
Start-ServicesasvStarts one or more stopped services.Cmdlet
Unblock-FileUnblocks files that were downloaded from the Internet.Cmdlet
Get-DiskGets one or more disks visible to the operating system.Function
Get-ModulegmoGets the modules that have been imported or that can be imported into the current session.Cmdlet
ConvertTo-JsonConverts an object to a JSON-formatted string.Cmdlet
New-WebServiceProxyCreates a Web service proxy object that lets you use and manage the Web service in Windows PowerShell.Cmdlet
Reset-ComputerMachinePasswordResets the machine account password for the computer.Cmdlet
Get-ScheduledTaskGets the task definition object of a scheduled task that is registered on the local computer.Function
Write-EventLogWrites an event to an event log.Cmdlet
Set-ServiceStarts, stops, and suspends a service, and changes its properties.Cmdlet
Out-StringSends objects to the host as a series of strings.Cmdlet
Get-PrinterRetrieves a list of printers installed on a computer.Function
Out-NullDeletes output instead of sending it down the pipeline.Cmdlet
Resolve-DnsNameundefinedCmdlet
Get-WindowsUpdateLogMerges Windows Update .etl files into a single log file.Function
Restart-ServiceStops and then starts one or more services.Cmdlet
Set-Variableset, svSets the value of a variable. Creates the variable if one with the requested name does not exist.Cmdlet
Compress-ArchiveCreates an archive, or zipped file, from specified files and folders.Function
ConvertFrom-JsonConverts a JSON-formatted string to a custom object.Cmdlet
New-SmbShareCreates an SMB share.Function
Set-ItemsiChanges the value of an item to the value specified in the command.Cmdlet
Update-HelpDownloads and installs the newest help files on your computer.Cmdlet
Group-ObjectgroupGroups objects that contain the same value for specified properties.Cmdlet
Start-BitsTransferCreates a BITS transfer job.Cmdlet
Get-CertificateSubmits a certificate request to an enrollment server and installs the response or retrieves a certificate for apreviously submitted request.Cmdlet
Register-ScheduledTaskRegisters a scheduled task definition on a local computer.Function
Tee-ObjectteeSaves command output in a file or variable and also sends it down the pipeline.Cmdlet
Test-ComputerSecureChannelTests and repairs the secure channel between the local computer and its domain.Cmdlet
Measure-CommandMeasures the time it takes to run script blocks and cmdlets.Cmdlet
ConvertFrom-SecureStringConverts a secure string to an encrypted standard string.Cmdlet
Get-JobgjbGets Windows PowerShell background jobs that are running in the current session.Cmdlet
Export-ClixmlCreates an XML-based representation of an object or objects and stores it in a file.Cmdlet
ConvertTo-CsvConverts objects into a series of comma-separated value (CSV) variable-length strings.Cmdlet
Remove-AppxProvisionedPackageRemoves an app package (.appx) from a Windows image.Cmdlet
New-ItemPropertyCreates a new property for an item and sets its value.Cmdlet
Get-PhysicalDiskGets a list of all PhysicalDisk objects visible across any available Storage Management Providers, or optionally afiltered list.Function
Set-TimeZoneSets the system time zone to a specified time zone.Cmdlet
Get-PackageReturns a list of all software packages that have been installed by using Package Management.Cmdlet
Get-SmbShareRetrieves the SMB shares on the computer.Function
Get-VariablegvGets the variables in the current console.Cmdlet
Add-PrinterAdds a printer to the specified computer.Function
Resolve-PathrvpaResolves the wildcard characters in a path, and displays the path contents.Cmdlet
Select-XmlFinds text in an XML string or document.Cmdlet
Get-RandomGets a random number, or selects objects randomly from a collection.Cmdlet
Get-PSDrivegdrGets drives in the current session.Cmdlet
Expand-ArchiveExtracts files from a specified archive (zipped) file.Function
Receive-JobrcjbGets the results of the Windows PowerShell background jobs in the current session.Cmdlet
New-NetFirewallRuleCreates a new inbound or outbound firewall rule and adds the rule to the target computer.Function
New-NetIPAddressCreates and configures an IP address.Function
Get-NetIPAddressGets the IP address configuration.Function
Register-ObjectEventSubscribes to the events that are generated by a Microsoft .NET Framework object.Cmdlet
Get-SmbConnectionRetrieves the connections established from the SMB client to the SMB servers.Function
New-TimeSpanCreates a TimeSpan object.Cmdlet
Enable-WindowsOptionalFeatureEnables a feature in a Windows image.Cmdlet
Set-NetConnectionProfileChanges the network category of a connection profile.Function
New-ScheduledTaskTriggerCreates a scheduled task trigger object.Function
Rename-ComputerRenames a computer.Cmdlet
Get-EventGets the events in the event queue.Cmdlet
Test-WSManTests whether the WinRM service is running on a local or remote computer.Cmdlet
Get-AppxProvisionedPackageGets information about app packages (.appx) in an image that will be installed for each new user.Cmdlet
Wait-ProcessWaits for the processes to be stopped before accepting more input.Cmdlet
Wait-JobwjbSuppresses the command prompt until one or all of the Windows PowerShell background jobs running in the sessionare completed.Cmdlet
Write-DebugWrites a debug message to the console.Cmdlet
Import-CertificateImports one or more certificates into a certificate store.Cmdlet
New-EventLogCreates a new event log and a new event source on a local or remote computer.Cmdlet
Get-HostGets an object that represents the current host program.Cmdlet
Invoke-WmiMethodCalls WMI methods.Cmdlet
Update-ScriptUpdates a script.Function
New-ServiceCreates a new Windows service.Cmdlet
ConvertFrom-CsvConverts object properties in comma-separated value (CSV) format into CSV versions of the original objects.Cmdlet
Invoke-ItemiiPerforms the default action on the specified item.Cmdlet
Enable-WSManCredSSPEnables CredSSP authentication on a computer.Cmdlet
Get-UniqueguReturns unique items from a sorted list.Cmdlet
Find-PackageFinds software packages in available package sources.Cmdlet
Out-HostohSends output to the command line.Cmdlet
Format-VolumeFormats one or more existing volumes or a new volume on an existing partition.Function
Format-CustomfcUses a customized view to format the output.Cmdlet
Get-SmbServerConfigurationRetrieves the SMB server configuration.Function
Mount-DiskImageMounts a previously created disk image (virtual hard disk or ISO), making it appear as a normal disk.Function
Clear-Hostclear, clsClears the display in the host program.Function
Start-DscConfigurationApplies configuration to nodes.Cmdlet
Get-SmbOpenFileRetrieves basic information about the files that are open on behalf of the clients of the SMB server.Function
Add-VpnConnectionAdds a VPN connection to the Connection Manager phone book.Function
Set-DnsClientServerAddressSets DNS server addresses associated with the TCP/IP properties on an interface.Function
Export-ModuleMemberSpecifies the module members that are exported.Cmdlet
Get-PSSessiongsnGets the Windows PowerShell sessions on local and remote computers.Cmdlet
Get-PSSnapinGets the Windows PowerShell snap-ins on the computer.Cmdlet
Get-NetConnectionProfileGets a connection profile.Function
Get-NetFirewallRuleRetrieves firewall rules from the target computer.Function
Push-LocationpushdAdds the current location to the top of a location stack.Cmdlet
Get-VolumeGets the specified Volume object, or all Volume objects if no filter is provided.Function
New-NetLbfoTeamCreates a new NIC team.Function
Get-NetTCPConnectionGets TCP connections.Function
Stop-ComputerStops (shuts down) local and remote computers.Cmdlet
Set-StrictModeEstablishes and enforces coding rules in expressions, scripts, and script blocks.Cmdlet
Set-NetFirewallRuleModifies existing firewall rules.Function
Add-AppxProvisionedPackageAdds an app package (.appx) that will install for each new user to a Windows image.Cmdlet
Enable-BitLockerEnables encryption for a BitLocker volume.Function
Get-Locationgl, pwdGets information about the current working location or a location stack.Cmdlet
Set-NetIPInterfaceModifies an IP interface.Function
New-VirtualDiskCreates a new virtual disk in the specified storage pool.Function
Remove-PSSessionrsnCloses one or more Windows PowerShell sessions (PSSessions).Cmdlet
Set-NetIPAddressModifies the configuration of an IP address.Function
Register-ScheduledJobCreates a scheduled job.Cmdlet
Set-SmbServerConfigurationSets the SMB Service configuration.Function
New-PartitionCreates a new partition on an existing Disk object.Function
Remove-PSDriverdrDeletes temporary Windows PowerShell drives and disconnects mapped network drives.Cmdlet
Remove-VariablervDeletes a variable and its value.Cmdlet
Get-WindowsOptionalFeatureGets information about optional features in a Windows image.Cmdlet
Import-ClixmlImports a CLIXML file and creates corresponding objects in Windows PowerShell.Cmdlet
Import-PfxCertificateImports certificates and private keys from a Personal Information Exchange (PFX) file to the destination store.Cmdlet
Uninstall-PackageUninstalls one or more software packages.Cmdlet
Set-AuthenticodeSignatureAdds an Authenticode signature to a Windows PowerShell script or other file.Cmdlet
Set-NetAdapterSets the basic network adapter properties.Function
Set-AliassalCreates or changes an alias for a cmdlet or other command element in the current Windows PowerShell session.Cmdlet
Set-WmiInstanceCreates or updates an instance of an existing Windows Management Instrumentation (WMI) class.Cmdlet
Disable-WindowsOptionalFeatureDisables a feature in a Windows image.Cmdlet
Update-ModuleDownloads and installs the newest version of specified modules from an online gallery to the local computer.Function
New-LocalUserCreates a local user account.Cmdlet
Mount-WindowsImageMounts a Windows image in a WIM or VHD file to a directory on the local computer.Cmdlet
Get-ItemPropertyValuegpvGets the value for one or more properties of a specified item.Cmdlet
New-AliasnalCreates a new alias.Cmdlet
New-JobTriggerCreates a job trigger for a scheduled job.Cmdlet
Get-Historyghy, h, historyGets a list of the commands entered during the current session.Cmdlet
New-CimSessionCreates a CIM session.Cmdlet
Get-LocalGroupGets the local security groups.Cmdlet
ConvertTo-XmlCreates an XML-based representation of an object.Cmdlet
New-PSSessionOptionCreates an object that contains advanced options for a PSSession.Cmdlet
Add-WindowsCapabilityInstalls a Windows capability package on the specified operating system image.Cmdlet
New-VariablenvCreates a new variable.Cmdlet
Convert-PathcvpaConverts a path from a Windows PowerShell path to a Windows PowerShell provider path.Cmdlet
Get-LocalGroupMemberGets members from a local group.Cmdlet
Add-WindowsPackageAdds a single .cab or .msu file to a Windows image.Cmdlet
Invoke-CimMethodInvokes a method of a CIM class.Cmdlet
ConvertFrom-StringCFSExtracts and parses structured properties from string content.Cmdlet
Export-CertificateExports a certificate from a certificate store into a file.Cmdlet
Unregister-ScheduledTaskUnregisters a scheduled task.Function
ConvertFrom-StringDataConverts a string containing one or more key and value pairs to a hash table.Cmdlet
Install-PackageProviderInstalls one or more Package Management package providers.Cmdlet
Get-LocalUserGets local user accounts.Cmdlet
Clear-ContentclcDeletes the contents of an item, but does not delete the item.Cmdlet
Remove-ModulermoRemoves modules from the current session.Cmdlet
Get-VpnConnectionRetrieves the specified VPN connection profile information.Function
Export-PfxCertificateExports a certificate or a PFXData object to a Personal Information Exchange (PFX) file.Cmdlet
Get-NetIPConfigurationGets IP network configuration.Function
Export-WindowsDriverExports all third-party drivers from a Windows image to a destination folder.Cmdlet
Grant-SmbShareAccessAdds an allow ACE for a trustee to the security descriptor of the SMB share.Function
Initialize-DiskInitializes a RAW disk for first time use, enabling the disk to be formatted and used to store data.Function
Get-NetIPInterfaceGets an IP interface.Function
Get-PfxCertificateGets information about .pfx certificate files on the computer.Cmdlet
Invoke-PesterInvokes Pester to run all tests (files containing *.Tests.ps1) recursively under the PathFunction
Add-OdbcDsnAdds an ODBC DSN.Function
Format-WidefwFormats objects as a wide table that displays only one property of each object.Cmdlet
Get-PartitionReturns a list of all partition objects visible on all disks, or optionally a filtered list using specifiedparameters.Function
Set-DiskTakes a Disk object or unique disk identifiers and a set of attributes, and updates the physical disk on thesystem.Function
Get-ScheduledJobGets scheduled jobs on the local computer.Cmdlet
Get-PnpDeviceReturns information about PnP devices.Function
Get-TpmGets an object that contains information about a TPM.Cmdlet
Disable-NetAdapterBindingDisables a binding to a network adapter.Function
Get-PSRepositoryGets PowerShell repositories.Function
Out-DefaultSends the output to the default formatter and to the default output cmdlet.Cmdlet
Add-PrinterDriverInstalls a printer driver on the specified computer.Function
Set-WinUserLanguageListSets the language list and associated properties for the current user account.Cmdlet
Get-ScheduledTaskInfoGets run-time information for a scheduled task.Function
Enable-NetFirewallRuleEnables a previously disabled firewall rule.Function
Out-PrinterlpSends output to a printer.Cmdlet
Add-PrinterPortInstalls a printer port on the specified computer.Function
Set-WinSystemLocaleSets the system locale (the language for non-Unicode programs) for the current computer.Cmdlet
Find-ModuleFinds modules from an online gallery that match specified criteria.Function
Get-NetAdapterVmqGets the VMQ properties of a network adapter.Function
Stop-TranscriptStops a transcript.Cmdlet
Get-SmbSessionRetrieves information about the SMB sessions that are currently established between the SMB server and theassociated clients.Function
Set-PSSessionConfigurationChanges the properties of a registered session configuration.Cmdlet
Add-MpPreferenceModifies settings for Windows Defender.Function
Set-SmbShareModifies the properties of the SMB share.Function
Set-VpnConnectionChanges the configuration settings of an existing VPN connection profile.Function
Start-ScheduledTaskStarts one or more instances of a scheduled task.Function
Suspend-BitLockerSuspends Bitlocker encryption for the specified volume.Function
Get-SmbShareAccessRetrieves the ACL of the SMB share.Function
Set-PSDebugTurns script debugging features on and off, sets the trace level, and toggles strict mode.Cmdlet
Get-StartAppsGets the names and AppIDs of installed apps.Function
Add-VpnConnectionRouteAdds a route to a VPN connection.Function
Get-VirtualDiskReturns a list of VirtualDisk objects, across all storage pools, across all providers, or optionally a filteredsubset based on provided criteria.Function
Write-InformationSpecifies how Windows PowerShell handles information stream data for a command.Cmdlet
New-ScheduledTaskCreates a scheduled task instance.Function
Set-CultureSets the user culture for the current user account.Cmdlet
New-ScheduledTaskSettingsSetCreates a new scheduled task settings object.Function
New-ScheduledTaskActionCreates a scheduled task action.Function
Set-PartitionSets attributes of a partition, such as active, read-only, and offline states.Function
Clear-VariableclvDeletes the value of a variable.Cmdlet
Add-KdsRootKeyGenerates a new root key for the Microsoft Group KdsSvc within Active Directory.Cmdlet
Exit-PSSessionexsnEnds an interactive session with a remote computer.Cmdlet
Add-LocalGroupMemberAdds members to a local group.Cmdlet
Set-LocalUserModifies a local user account.Cmdlet
Remove-ComputerRemoves the local computer from its domain.Cmdlet
New-NetNatCreates a NAT object.Function
Set-SmbClientConfigurationSets the SMB client configuration.Function
Set-ScheduledTaskModifies a scheduled task.Function
Remove-ItemPropertyrpDeletes the property and its value from an item.Cmdlet
Set-PrinterUpdates the configuration of an existing printer.Function
Set-PhysicalDiskSets attributes on a specific physical disk.Function
Set-DateChanges the system time on the computer to a time that you specify.Cmdlet
Repair-WindowsImageRepairs a Windows image in a WIM or VHD file.Cmdlet
Set-NetAdapterVmqSets the VMQ properties of a network adapter.Function
Remove-WmiObjectDeletes an instance of an existing Windows Management Instrumentation (WMI) class.Cmdlet
New-NetRouteCreates a route in the IP routing table.Function
Optimize-VolumeOptimizes a volume.Function
New-VolumeCreates a volume with the specified file system.Function
New-StoragePoolCreates a new storage pool using a group of physical disks.Function
New-SmbMappingCreates an SMB mapping.Function
Set-DscLocalConfigurationManagerApplies LCM settings to nodes.Cmdlet
New-ScheduledTaskPrincipalCreates an object that contains a scheduled task principal.Function
Get-CultureGets the current culture set in the operating system.Cmdlet
Set-PSRepositorySets values for a registered repository.Function
Set-NetFirewallProfileConfigures settings that apply to the per-profile configurations of the Windows Firewall with Advanced Security.Function
Get-AliasgalGets the aliases for the current session.Cmdlet
Get-DnsClientServerAddressGets DNS server IP addresses from the TCP/IP properties on an interface.Function
Set-MpPreferenceConfigures preferences for Windows Defender scans and updates.Function
Save-ModuleSaves a module locally without installing it.Function
Resize-PartitionResizes a partition and the underlying file system.Function
Repair-VolumePerforms repairs on a volume.Function
Remove-PrinterRemoves a printer from the specified computer.Function
Remove-PhysicalDiskRemoves a physical disk from a specified storage pool.Function
Remove-NetIPAddressRemoves an IP address and its configuration.Function
Register-PSRepositoryRegisters a PowerShell repository.Function
Get-WindowsCapabilityGets Windows capabilities for an image or a running operating system.Cmdlet
Get-BitLockerVolumeGets information about volumes that BitLocker can protect.Function
Get-ClipboardGets the current Windows clipboard entry.Cmdlet
Get-ComputerInfoGets a consolidated object of system and operating system properties.Cmdlet
Get-InitiatorPortGets one or more host bus adapter (HBA) initiator ports.Function
Get-BitsTransferGets the associated BitsJob object for an existing BITS transfer job.Cmdlet
Get-AuthenticodeSignatureGets information about the Authenticode signature for a file.Cmdlet
Get-AppvClientPackageReturns App-V Client Packages.Cmdlet
Set-WSManQuickConfigConfigures the local computer for remote management.Cmdlet
New-GuidCreates a GUID.Function
Get-StorageJobReturns information about long-running Storage module jobs, such as a repair task.Function
Uninstall-ModuleUninstalls a module.Function
Get-InstalledModuleGets installed modules on a computer.Function
Confirm-SecureBootUEFIConfirms that Secure Boot is enabled by checking the Secure Boot status on the local computer.Cmdlet
Set-ClipboardSets the current Windows clipboard entry.Cmdlet
Get-TlsCipherSuiteGets the list of cipher suites for TLS for a computer.Cmdlet
Clear-DiskCleans a disk by removing all partition information and un-initializing it, erasing all data on the disk.Function

The data presented in this table are used under a CC BY 4.0 License. Modifications include syntactic styling.

Windows server core 远程管理

Windows server core 不带GUI,不像winserver 2003 那样容易使用, 但是可以使用Server Manager 来 远程管理。

先在server core 当中运行sconfig, 对服务器进行基本配置,设置服务器电脑名、IP。在管理端运行以下命令:

Set-Item wsman:\localhost\Client\TrustedHosts 服务器电脑名 -Concatenate -Force

将server core 加入信任的机器列表,然后就可以在管理端运行server manager 并添加server core 进行管理。但是Server manager 提供的功能很有限,推荐使用power shell 进行远程管理。

Cython编译python脚本成exe

Cython 可以把python代码翻译成c\c++源代码,然后就可以用cl,gcc等编译器编译成可执行文件。经过我的实际测试,支持tkinter,可以生成带图形界面的程序,可以去掉黑框。

cython -3 --embed -o run.c run.py
cl /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I"C:\Program Files\Python37\include" /Tc run.c /DWIN32
link run.obj /SUBSYSTEM:CONSOLE /MACHINE:X64 /LIBPATH:"C:\Program Files\Python37\libs"
link run.obj /SUBSYSTEM:WINDOWS /MACHINE:X64 /LIBPATH:"C:\Program Files\Python37\libs" /ENTRY:"wmainCRTStartup"

生成的可执行文件任然依赖于python的运行时环境(如python.dll, 程序使用到的标准模块pyd等,而且必须是同一版本的运行时)。Cython不能把所有依赖打包成一个包,如果需要将所有依赖打包并复制到未安装python的电脑上运行,则比较麻烦。

另一个打包工具nuikta,可以把所有依赖打包到一个文件夹里,但是不能生成单独的exe。Nuikta的使用方法更简单。

如果你总是不能收到广播包,该怎么办?

最近在写一个udp通信的程序,由于需要先发送一个广播包,然后等待接收一个回复。

最开始发包(sendto)的时候,一切顺利,但是后来死活不能接收广播包。recvfrom 要么超时,要么一直堵塞着(blocked),耽搁了一天的时间,后来仔细谷歌,才发现是因为内核使用了反向过滤的技术。只要关闭就行了。怎么关闭呢:

以root身份运行:

sysctl -w  net.ipv4.conf.all.rp_filter=0

sysctl -w  net.ipv4.conf.eth0.rp_filter=0

其实该技术打开时,不只是广播包会被内核丢弃,组播包也会被丢弃。现付上一个参考连接:https://www.centos.org/forums/viewtopic.php?t=7775

由于浪费了我不少时间,现将此情况记录起来,希望此文能帮助到你。

if (recvfrom(sock, (void*)dhcp_reply, sizeof(dhcp_reply), 0, (struct sockaddr*)&servAddr, (socklen_t*)&revedAddrLen) == -1) {
			fprintf(stderr, "未收到 DHCP Offer消息:%s\n请尝试用root用户运行 sysctl -w  net.ipv4.conf.all.rp_filter=0\nsysctl -w  net.ipv4.conf.eth1.rp_filter=0", strerror(errno));
			exit(-1);
		}

 

SIA coin 小记

今天,在网络上偶然发现了一个叫 sia 的基于区块链的云储存服务开源软件。官方网址https://sia.tech,GITHUB网址:https://github.com/NebulousLabs/Sia

该软件发行了一种SIA coin的数字货币,该数字货币的目标不像比特币想作为一种通用现金那样宏伟。SIA coin 是作为自己自己平台上的一种服务凭证,更相当于现实生活中商家发行的消费券、代金券这样的私人凭证。

SIA整个系统向外部提供收费云储存服务,用户可以通过SIA-GUI软件向SIA系统上传自己的文件,文件在上传之前会加密,加密后的内容会上传于多个Host上。同时用户在上传时,也必须声明要保存的时间,比如说一年,两年或者还是保存3个月。文件体积越大、时间越长需要的SIA coin越多。

Host 就是向外部提供储存服务的主要节点,其实更相当于快递商的加盟模式,任何一台因特网上的主机,只要具备几个条件,就可以成为一个Host,而向外部出租自己多余的储存空间和宽带。目前的条件有,(条件不一定完全准确,因为我不能确定自己看到的是不是最新资料):

1、需要一个公网IP,或者一个稳定的域名,可以让SIA的客户(他们叫renter)来访问到你的host

2、Host主机最少可以提供不小12周内至少95%的上线率,就是说你的host主机在线时间不能少95%

3、你需要有中够的sia coin 用于抵押担保,你能按时按量正确地保存客户的资料,SIA 系统里的智能合约(smart contract) 会随时让你的host 证明你仍然保存着用户的文件(Storage prove) 如果你的host 不能证明着你还保存着用户的文件,你用于抵押的sia coin 就将被合约转给用户,以补偿用户的损失。

 

目前SIA 官方网站上声称可以提供比amazon S3 更便宜的云储存服务。

数字货币开源交易机器人汇总

近期花了三天时间了解了下网络上开源的加密货币交易机器人,现在备忘如下:

1、vnpy 量化交易平台

vn.py项目起源于国内私募的自主交易系统,2015年初启动时只是单纯的交易API接口的Python封装。随着业内关注度的上升和社区不断的贡献,目前已经一步步成长为一套全面的交易程序开发框架,用户群体也日渐多样化,包括私募基金、证券自营和资管、期货资管和子公司、高校研究机构、个人投资者等。

2、gocryptotrader

Cryptocurrency trading bot written in Golang

Build Status Test Coverage

A cryptocurrency trading bot supporting multiple exchanges written in Golang.

Please note that this bot is under development and is not ready for production!

Exchange Support Table

Exchange REST API Streaming API FIX API
Alphapoint Yes Yes NA
ANXPRO Yes No NA
Bitfinex Yes Yes NA
Bitstamp Yes Yes NA
BTCC Yes Yes No
BTCE Yes NA NA
BTCMarkets Yes NA NA
GDAX(Coinbase) Yes Yes No
Gemini Yes NA NA
Huobi Yes Yes No
ItBit Yes NA NA
Kraken Yes NA NA
LakeBTC Yes Yes NA
LocalBitcoins Yes NA NA
OKCoin (both) Yes Yes No
Poloniex Yes Yes NA

** NA means not applicable as the Exchange does not support the feature.

Current Features

  • Support for all Exchange fiat and digital currencies, with the ability to individually toggle them on/off.
  • REST API support for all exchanges.
  • Websocket support for applicable exchanges.
  • Ability to turn off/on certain exchanges.
  • Ability to adjust manual polling timer for exchanges.
  • SMS notification support via SMS Gateway.
  • Basic event trigger system.

Planned Features

  • WebGUI.
  • FIX support.
  • Expanding event trigger system.
  • TALib.
  • Trade history summary generation for tax purposes.

Please feel free to submit any pull requests or suggest any desired features to be added.

Compiling instructions

Download Go from https://golang.org/dl/
Using a terminal, type go get github.com/thrasher-/gocryptotrader
Change directory to the package directory, then type go install.
Copy config_example.json to config.json.
Make any neccessary changes to the config file.
Run the application!

Binaries

Binaries will be published once the codebase reaches a stable condition.

3、cointrader

Coin Trader

Coin Trader is a Java-based backend for trading cryptocurrencies, released under the Apache License. It features:

  • Connectivity to many exchanges
  • Control console (text)
  • Basic order routing
  • Simulated trading
  • Live order execution
  • Schema and persistence
  • CSV output of market data
  • Ad-hoc table reports
  • Modular infrastructure
  • Backtesting
  • Accounting
  • Library of quantitative indicators (TaLib)
  • Bitcoin derivatives (Futures & Swaps)
  • Implied price calculation across multiple markets
  • Base currency accounting
  • 24 Hr OHLC bars

Coin Trader’s future goals include:

  • Reconciliation
  • Flexible data output
  • Web console & graphing

Video

Tim presents Coin Trader at the SF Bitcoin Dev meetup.

Setup

Coin Trader requires Java JDK 1.7, Maven, and a SQL database (MySQL default).
Setup Instructions

Support

See the Wiki for more information.
There’s no mailing list, so open a new issue for anything, help or just discussion. Tag it with “Question” and I’ll follow through with you.

Automated Trading

To implement signals and automated strategies, you connect Esper event queries to Java code like this:

@When( "select avg(priceAsDouble) from Trade.win:time(30 sec)" )
void checkMovingAverage( double avg )
{
  if( avg > trigger )
    context.publish( new MyIndicator(5.31) );
}

@When( "select * from MyIndicator where myIndicatorValue > 5.0" )
void enterTrade( MyIndicator s )
{
  orders.create( Listings.BTC_USD, 1.0 )
        .withLimit( 650.25 )
        .place();
}

You then attach this class to a Context to receive Esper event rows as method invocations.

24Hr OHLC Bars

Strategy needs to implement a .getInterval() method to return a double in seconds of the size of the bar.

Default simple statful stretegy is 86400 (24Hr) cointrader-esper.cfg.xml

<plugin-view factory-class="org.cryptocoinpartners.esper.OHLCBarPlugInViewFactory" name="ohlcbar" namespace="custom"/>  

epl

  • Create an esper named window to add the OHLC bars into
create window OHLCShortWindow.win:length(10)
as
    select *
from
    Bar;
  • Add the OHLC bars to it
insert into OHLCShortWindow
select * 
 from  Trade.custom:ohlcbar(timestamp, priceCountAsDouble, market,TestStrategy.getInterval());

  • Select values from OHLC bar window
select * from OHLCShortWindow as ohlc 

TALIB Set Up

cointrader-esper.cfg.xml

<plugin-aggregation-function name="talib" function-class="org.cryptocoinpartners.esper.GenericTALibFunction"/>  

epl

select coalesce(talib("atr", max, min, last, 9),0) as atr from OHLCShortWindow;

Console Demo

The Coin Trader Console gives you a peek into the engine.

$ ./cointrader.sh console

Coin Trader Console 0.3.0-SNAPSHOT

ct> help
Type "help {command}" for more detailed information.
Available commands:
    • attach
    • buy
    • csv
    • currencies
    • data
    • exchanges
    • exit
    • help
    • jpa
    • listings
    • markets
    • sell
    • set
    • unset
    • unwatch
    • watch
    • watches

ct> data summary
+------------------+------------+-----------+
|      Market      | Num Trades | Num Books |
+------------------+------------+-----------+
|     BTCE:BTC.USD |       8149 |      2671 |
| BITFINEX:BTC.USD |       3509 |      2551 |
| BITSTAMP:BTC.USD |       1344 |       901 |
| BITFINEX:DRK.USD |       1000 |        21 |
| BITFINEX:DRK.BTC |       1000 |        21 |
| BITFINEX:LTC.USD |       1000 |        22 |
| BITFINEX:LTC.BTC |       1000 |        22 |
| BTCCHINA:BTC.CNY |        134 |        31 |
| BTCCHINA:LTC.CNY |        110 |        31 |
| BTCCHINA:LTC.BTC |        102 |        31 |
|     BTER:BTC.CNY |         47 |         7 |
|     BTER:LTC.BTC |         38 |        84 |
|    BTER:DOGE.CNY |         26 |         7 |
|     BTER:NXT.CNY |         26 |         6 |
|     BTER:DRK.CNY |         23 |         6 |
|    BTER:DOGE.BTC |         23 |         6 |
|     BTER:LTC.CNY |         21 |         7 |
|     BTER:XCP.CNY |         20 |         6 |
|     BTER:DRK.BTC |         19 |         6 |
|     BTER:XCP.BTC |         18 |        12 |
|     BTER:NXT.USD |          2 |         6 |
+------------------+------------+-----------+

ct> watch btc.usd
now watching BTC.USD

ct> 
book: BITFINEX:BTC.USD    587.4 (0.317861) - 588.82 (-1.54641998)
book: BTCE:BTC.USD    583.92 (0.01499999) - 585.99 (-0.01819054)
book: BITSTAMP:BTC.USD    588.79 (0.99999999) - 590.33 (-0.19199999)
book: BITFINEX:BTC.USD    587.4 (0.317861) - 588.81 (-13.94196839)
book: BTCE:BTC.USD    583.92 (0.01499999) - 585.99 (-0.01819054)
trade: BITSTAMP:BTC.USD    590.33 (0.03489999)
book: BTCE:BTC.USD    583.92 (0.01499999) - 585.99 (-0.01819054)
book: BITFINEX:BTC.USD    587.4 (0.317861) - 588.8 (-31.37994228)
book: BTCE:BTC.USD    583.92 (0.01499999) - 585.99 (-0.01180944)

ct> unwatch btc.usd
no longer watching BTC.USD

ct> buy 10.0 bitfinex:btc.usd
Sending order SpecificOrder{id=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, parentOrder=null, market=BITFINEX:BTC.USD, volumeCount=1000000000}
Order has been placed. SpecificOrder{id=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, parentOrder=null, market=BITFINEX:BTC.USD, volumeCount=1000000000}

ct> 
Filled order d5a2ff79-0eca-445d-a3b3-75d1e80265a7: Fill{order=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, market=BITFINEX:BTC.USD, price=585.57, volume=2.11486695}
Order is partially filled SpecificOrder{id=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, parentOrder=null, market=BITFINEX:BTC.USD, volumeCount=1000000000, averageFillPrice=585.57}
Filled order d5a2ff79-0eca-445d-a3b3-75d1e80265a7: Fill{order=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, market=BITFINEX:BTC.USD, price=585.58, volume=7.88513305}
Order has been completely filled.  SpecificOrder{id=d5a2ff79-0eca-445d-a3b3-75d1e80265a7, parentOrder=null, market=BITFINEX:BTC.USD, volumeCount=1000000000, averageFillPrice=585.57788513305}

ct> buy 1 btc.usd
Creating order GeneralOrder{id=a4664af4-a21d-4b77-a999-bc8a78a8d951, parentOrder=null, listing=BTC.USD, volume=1}
Order has been placed. SpecificOrder{id=3ff02408-8269-4bf9-929f-8d2ca060f6fc, parentOrder=a4664af4-a21d-4b77-a999-bc8a78a8d951, market=BITSTAMP:BTC.USD, volumeCount=100000000}

ct>
Filled order 3ff02408-8269-4bf9-929f-8d2ca060f6fc: Fill{order=3ff02408-8269-4bf9-929f-8d2ca060f6fc, market=BITSTAMP:BTC.USD, price=584.99, volume=1}
Order has been completely filled.  SpecificOrder{id=3ff02408-8269-4bf9-929f-8d2ca060f6fc, parentOrder=a4664af4-a21d-4b77-a999-bc8a78a8d951, market=BITSTAMP:BTC.USD, volumeCount=100000000, averageFillPrice=584.99}
Order has been completely filled.  GeneralOrder{id=a4664af4-a21d-4b77-a999-bc8a78a8d951, parentOrder=null, listing=BTC.USD, volume=1}

ct> buy 1 OKCOIN_THISWEEK:BTC.USD.THISWEEK limit 218.3

ct> exit

$

转 Esper开发之一

By: rsljdkt

参考:

esper官网:http://esper.codehaus.org/

说明:

本文定位:初学者

本文主要内容:介绍Esper的基本概念和应用背景,Esper的学习步骤。在文章最后,介绍了Esper的”HelloWorld”。

一、CEP和ESP的概念  

CEP,:Complex Event Process,复杂事件处理,是一种新兴的基于事件流的技术,它用于处理事件,从事件流中发现复杂的模式。它将系统数据看做不同类型的事件,通过分析事件间的关系,建立不同事件关系序列库,利用过滤、关联、聚合等技术,最终由简单事件产生高级事件或商业流程。

ESP,Event Stream Process,事件流处理,目的是从事件流中获得有用的事件,进而从中获得有用信息。实时OLAP(联机分析处理)和连续查询者两个术语常常和ESP是同义语。

CEP/ESP适合的应用场景包括商业活动监控、群众智能、犯罪预防、系统动态校验实时风险分析、网络攻击、市场趋势分析等等。商业CEP产品厂商有Oracle、IBM等。

二、什么是Esper 

Esper官网是这么定义的:”Esper is a component for CEP and ESP applications”,中文意思是:Esper是用于CEP(复杂事件处理)和ESP(事件流处理)应用程序的组件。

Esper是纯Java开源复杂事件和事件流引擎,可以监测事件流,并在特定事件发生时触发某些动作。Esper引擎是为了满足事件进行分析并做出反应等这些应用需求而产生的。这些应用要求实时或者接近实时处理事件(或消息)。这类应用具有高吞吐量、低响应时间和复杂的计算等特点。

Esper引擎的典型应用有:

Ø 业务处理管理和自动化(处理监控,业务活动监控,异常报告,经营智能化等等)

Ø 财务(算法交易,欺诈检查,风险管理)

Ø 网络及应用程序监控(入侵检测,SLA(Service Level Agreement)监控)

Ø 传感器网络应用(RFID 读取,生产线调度和控制,空中交通)

Esper初学者的学习步骤(这是Esper参考手册上推荐的):

1.阅读Esper官网上的tutorials,  case  studies  and  solution  patterns。

   n Tutorial-本篇是 Esper 的教程,主要介绍了(1)什么是Esper,它有什么优点,包括哪些component(2)什么是事件流,什么是复杂事件。(3)什么是 EPL(4)如何开发一个事件驱动的应用(5)如何设计事件(6)事件流分析(7)事件模式匹配(8)如何结合事件流分析与模式匹配

   n Quick Start – 本篇主要描述如何快速使用 Esper,包括(1)安装 (2)创建Java事件类,POJO对象作为事件(3)创建一个 Statement (4)添加一个Listener(5)发送事件(6)Esper配置

   n Articles and Presentations, 文章和报告,这里列举了某些文章和展示材料,有些sample可以下载,对于学习和熟悉很有帮助

   n Solution Patterns,解决方案模式,使用Q&A的模式,对CEP 和 Esper 进行阐述,对于整个 Esper 的背景知识,会有很大帮助

   n Short Case Study, 简短的个案研究,以传输监控为例,进行分析,

   n Longer Case Study,较大个案研究,多个事件构成一次事务,对此进行分析

   n Additional Examples,其它示例,描述了怎么在 JMS, J2EE等环境里使用

   n Technology Links,技术链接,一些参考网站的引用

   n Documentation,文档,这里有很多文档供下载到本地

   n Building Esper,介绍如何使用 Maven 来build Esper

2.阅读参考手册1.1节:CEP和事件流分析简介

3.阅读参考手册第2章:事件表达(介绍了Esper中表达事件的不同方法)

4.阅读参考手册第3章:处理模型(详细了解EPL连续查询的结果)

5.阅读参考手册4.1节:EPL介绍(使用EPL进行事件流处理)

6.阅读参考手册5.1节:事件模式概览

7.阅读参考手册6.1节:概览(使用正则表达式的事件模式)

8.阅读参考手册14.1:例子概览

9.阅读参考手册15章:性能(关于Esper引擎的性能)

 

 

 

三、Quick Start

下载Esper:

esper-4.0.0.zip

本例只需要一下jar包:

核心包:esper-4.0.0.jar

依赖包:antlr-runtime-3.2.jar

cglib-nodep-2.2.jar

commons-logging-1.1.1.jar

log4j-1.2.16.jar

使用Esper的基本步骤:

1.创建一个Event class

2.创建一个class实现UpdateListener接口

3.创建一个Configuration实例

4.通过EPServiceProviderManger获得EPServiceProvider对象

5.通过EPServcieProder和EPL查询语句,创建EPStatement

6.将listener和EPStatement挂钩

7.使用epService.getEPRuntime().sendEvent(event)向引擎发送事件

举个例子:

1.创建一个Event class

Java代码
  1. package org.rsljdkt.rsc.esper.event;
  2. public class OrderEvent {
  3.     public double price;
  4.     public String itemName;
  5.     public OrderEvent() {
  6.         super();
  7.     }
  8.     public OrderEvent(double price, String itemName) {
  9.         super();
  10.         this.price = price;
  11.         this.itemName = itemName;
  12.     }
  13.     public double getPrice() {
  14.         return price;
  15.     }
  16.     public String getItemName() {
  17.         return itemName;
  18.     }
  19. }

2.创建一个class实现UpdateListener接口

Java代码
  1. package org.rsljdkt.rsc.esper.listener;
  2. import com.espertech.esper.client.EventBean;
  3. import com.espertech.esper.client.UpdateListener;
  4. public class OrderListener implements UpdateListener {
  5.     @Override
  6.     public void update(EventBean[] newEvents, EventBean[] oldEvents) {
  7.         EventBean eb = newEvents[0];
  8.         System.out.println(eb.get(“avgPrice”));
  9.     }
  10. }

其余步骤:

Java代码
  1. import org.rsljdkt.rsc.esper.event.OrderEvent;
  2. import org.rsljdkt.rsc.esper.listener.OrderListener;
  3. import com.espertech.esper.client.Configuration;
  4. import com.espertech.esper.client.EPServiceProvider;
  5. import com.espertech.esper.client.EPServiceProviderManager;
  6. import com.espertech.esper.client.EPStatement;
  7. public class Main {
  8.     public static void main(String[] args) {
  9.         //Creating a configuration
  10.         Configuration config= new Configuration();
  11.         config.addEventTypeAutoName(“org.rsljdkt.rsc.esper.event”);//添加包路径,这样在查询表达式中就不需要写类的全路径了
  12.         //Creating a statement
  13.         EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
  14.         //查询最近30秒钟到达的OrderEvent事件平均价格
  15.         String expression = “Select Avg(price) As avgPrice From OrderEvent.win:time(30 sec)”;
  16.         EPStatement statement = epService.getEPAdministrator().createEPL(expression);
  17.         //Adding a listener
  18.         statement.addListener(new OrderListener());
  19.         //Sending events
  20.         for(int i = 0 ; i<10;i++){
  21.             epService.getEPRuntime().sendEvent(new OrderEvent((i+1)*10,“Name”+i));
  22.         }
  23.     }
  24. }

 

运行结果:

Java代码
  1. 10.0
  2. 15.0
  3. 20.0
  4. 25.0
  5. 30.0
  6. 35.0
  7. 40.0
  8. 45.0
  9. 50.0
  10. 55.0

 

 

<!–EndFragment–>

区块链主流开源技术体系介绍

一、     比特币体系

比特币(BitCoin)是最早也是全球最广泛使用和真正意义的去中心化区块链技术,因此他的开源技术体系非常值得参考。

比特币区块链的核心技术框架采用C++语言开发,共识算法采用POW算法,工作量(挖矿)证明获得记账权,容错50%,实现全网记账,公网性能TPS<7。

开源地址为:https://github.com/bitcoin/bitcoin

虽然说POW算法比较低效率和耗能,比特币区块链由于推出时间比较早又不够强大(如不支持智能合约),但不可否认的是,目前市场上相对成熟和稳定的区块链体系还是比特币。市面上群魔乱舞的山寨币,正是基于比特币的源代码照搬或小改动而创造的,在比特币区块链的体系基础上,还创造了几种区块链技术体系:

彩色币(染色币),彩色币本身就是比特币,是在历史上的创世交易里面被转移过的比特币。在技术上将比特币网络从其货币价值中抽离出来,它们具有一些特殊的属性,比如支持代理或聚集点,从而具有与比特币面值无关的价值。彩色币可以用作替代货币、商品证书、智能财产以及其他金融工具,如股票和债券等。

闪电网络,是为了解决比特币区块链的瓶颈处理能力而生的,他可以有效解决时延、容量扩展、最终性的问题,为比特币区块链提供了一个可扩展的微支付通道网络,使用闪电网络后,TPS最大可以扩展到300。交易双方若在区块链上预先设有支付通道,就可以多次、高频、双向地通过轧差方式实现瞬间确认的微支付;双方若无直接的点对点支付通道,只要网络中存在一条连通双方的、由多个支付通道构成的支付路径,闪电网络也可以利用这条支付路径实现资金在双方之间的可靠转移。

比特币侧链

侧链是以锚定比特币为基础的新型区块链,就像美金锚定到金条一样。比特币的在区块链相当在货币体系的黄金地位,因为他是最去中心化、最多分布节点、最公平区块链。侧链是以融合的方式实现加密货币金融生态的目标,而不是像其它加密货币一样排斥现有的系统。利用侧链,我们可以轻松的建立各种智能化的金融合约,股票、期货、衍生品等等。你可以有成千上万个锚定到比特币上的侧链,特性和目的各不相同,所有这些侧链依赖于比特币主区块链保障的弹性和稀缺性。比较著名的比特币侧链是Rootstock和BlockStream推出的元素链。

Rootstock是一个基于比特币侧链的开源智能合约平台,他使得比特币拥有了智能合约,基于Rootstock的智能合约能够运行无数应用,为核心比特币网络增加价值和功能。Rootstock使用一种比特币双向挂钩技术,这种双向挂钩以一种固定的转换率输送或输出Rootstock上的比特币,Rootstock双向挂钩是一种混合驱链和侧链的技术。更值得关注的是,Rootstock向后兼容以太坊,实现了以太坊虚拟机的一个改进版本,所以以太坊发布的DApps程序能够轻松地在Rootstock上使用,实现比特币级别的安全性和以太坊大量Dapps的复用性,更快的执行性并和比特币发生更强的相互作用。使用Rootstock可以将性能扩展到TPS为300。

元素链(Elements)是Blockstream的开源侧链项目,同样使用比特币双向挂钩技术,除了智能合约外,他还给比特币快速带来许多创新技术,包括私密交易、证据分离、相对锁定时间、新操作码、签名覆盖金额等等特性。核心技术框架采用C++语言开发,开源地址为:https://github.com/ElementsProject/elements

二、     以太坊ETH

刚结束的以太坊全球开发者大会DEVCON2,吸引了无数大牛到上海,可以看到,以太坊生态系统正在高速地成长着,正朝着成为“世界计算机”的目标前进。无论是the DAO众筹到攻击,还是ETH与ETC 分道扬镳,或者是各种以太坊生态的开发框架和应用,以太坊目前在区块链平台是最吸引眼球的。

以太坊是一个图灵完备的区块链一站式开发平台,采用多种编程语言实现协议,采用Go语言写的客户端作为默认客户端(即与以太坊网络交互的方法, 支持其他多种语言的客户端)。基于以太坊平台之上的应用是智能合约,这是以太坊的核心。智能合约配合友好的界面和外加一些额外的小支持,可以让用户基于合约搭建各种千变万化的DApp应用,这样使得开发人员开发区块链应用的门槛大大降低。

以太坊ETH的开源地址:https://github.com/ethereum/。以太坊的整个技术生态系统比较强大,同时迭代周期比较快,所以有比较强的生命力,但事物都有两面,对于依赖于以太坊特别是以太坊公网的商业应用来说,频繁的迭代升级和处于风口浪尖(被攻击),使得基于以太坊的商业应用,有时候不得不打足精神去跟以太坊一起升级维护和补丁。

目前以太坊正在正式运行1.0版本,采用的是POW挖矿的共识算法,目前公网的TPS是25笔,在开发中的1.5版本,将采用类POS的Casper算法,以使区块链的确认速度相对于POW的线性效率,达到指数级。采用Casper后将会更好的确认机制,以及大幅降低能量消耗。在规划的 2.0版本目标,TPS有望可以达到2000TPS。

以太坊的进一步开发介绍你可以参考我另外一篇文章《区块链应用开发入门》。

三、     IBM HyperLedger fabric

IBMHyperLedger,又叫 fabric,是一个带有可插入各种功能模块架构的区块链实施方案,他的目标是打造成一个由全社会来共同维护的一个超级账本。Elwin个人感觉fabric分层设计比较合理,模块化程度非常不错,虽然目前还是在完善阶段,并没有真正商用(最近IBM携手中国银联打造区块链为基础的忠诚积分交易系统,但还是属于探索试样项目),但以IBM的多年技术底蕴,fabric应该是大企业构建区块链底层的选择之一。

fabric架构核心逻辑有三条:Membership、Blockchain和Chaincode。MembershipServices这项服务用来管理节点身份、隐私、保密性、可审计性。Blockchain services使用建立在HTTP/2上的P2P协议来管理分布式账本,提供最有效的哈希算法来维护区块链世界状态的副本。采取可插拔的方式来根据具体需求来设置共识协议,比如PBFT,Raft,PoW和PoS等等,IBM首选PBFT算法。Chaincode services 会提供一种安全且轻量级的沙盒运行模式,来在VP节点上执行chaincode逻辑,类似以太坊的EVM虚拟机及其他上面运行的智能合约。

开源地址:https://github.com/hyperledger/fabric。Fabric的主要框架核心开发语言是Go语言,系统目标是15个验证节点下最理想情况下可以有100K TPS的性能,更适合于联盟链。

四、     比特股BitShare

比特股(BitShares)是区块链历史上里程碑式的产品之一,截至目前仍然是完整度最高、功能最丰富、性能最强大的区块链产品之一。比特股是可以看作是一个公司、货币甚至是一个社区。它提供的BitUSD等锚定资产是虚拟币历史上的一个最重要变革之一,能够极大消除虚拟货币被人诟病的波动性大的问题。

比特币低效率高能耗的POW算法,使得比特股及其DPos共识算法应运而生。有别于比特币特定的共识机制,DPos有一个内置的实时股权人投票系统,就像系统随时都在召开一个永不散场的股东大会,所有股东都在这里投票决定公司决策。与比特币相比,比特股系统的投票权牢牢掌握在股东手里,而不是雇员。比特股系统的去中心化程度紧紧掌握在比特股持有者们的手中,他们决定了出块受托人的个数。同时,作恶的受托人不会得到任何好处,并且很快就会被投票出局。此外,比特股内置了强大的账户权限设定、灵活的多重签名方式、白名单等特性,足以满足企业级的功能定制需求。

比特股的1.0开源地址是:https://github.com/bytemaster/bitshares,2.0开源库在:http://github.com/bitshares。他的核心技术框架采用C++语言开发,既适用于公有链,也适合于联盟链,只需要少量节点进行记账,TPS>500,容错50%,在比特股2.0中如果在最优的网络和硬件情况下可以达到最高100K的TPS。

五、     公证通Factom

公证通(Factom)利用比特币的区块链技术来革新商业社会和政府部门的数据管理和数据记录方式,也可以被理解为是一个不可撤销的发布系统,系统中的数据一经发布,便不可撤销,提供了一份准确、可验证、且无法篡改的审计跟踪记录。利用区块链技术帮助各种各样应用程序的开发,包括审计系统,医疗信息记录,供应链管理,投票系统,财产契据,法律应用,金融系统等。

建立在Factom基础之上的应用程序寻求能够直接利用区块链实现追踪资产和实现合约,而不用将交易记录写入区块链,Factom在自己的架构中记录条目。跟以太坊类似,Factom系统会创造一个叫Factoids的电子币。持有Factoids意味着有权使用Factom系统。只要把Factoids转化成输入积分便有权把数据写入Factom系统中。同时运行着Factom的联邦服务器也能收获Factoids作为维护系统的回报。Factom虽然同样基于比特币网络,但却并不是之前提到侧链或染色币的技术架构,Factom只将目录区块的哈希值锚定到比特币区块链。Factom很好地解决了比特币三个核心的约束和问题,速度、成本和区块链膨胀。

Factom中的政策和奖励机制与POS机制有相似之处。与其不同之处在于,Factom中只有一小部分的用户权益能够被认可。只有已经提交到系统的权益有投票权,而可转移的Factoid权益没有投票权,避免了POS机制的“股份磨损”和“没有人进行POS”问题。

公证通的开源地址是:https://github.com/FactomProject/FactomCode。他的核心技术框架采用GO语言开发,TPS是27笔左右(待考究)。

最新情况,Factom将不会只依赖于比特币区块链,他将会同样会通过整合以太坊区块链,以来确保存放的数据时时刻刻都是安全的。

六、     瑞波Ripple

瑞波(Ripple)是世界上第一个开放的支付网络,是基于区块连的点到点全球支付网络。通过这个支付网络,使你轻松、廉价并安全的把你的金钱转账到互联网上的任何一个人,无论他在世界的哪个地方,他可以转账任意一种货币,包括美元、欧元、人民币、日元或者比特币,简便易行快捷,交易确认在几秒以内完成,交易费用几乎是零,没有所谓的跨行异地以及跨国支付费用。

Ripple有两个重要概念,其一是推出Ripple币瑞波币——XRP,它作为Ripple网络的基础货币,就像比特币一样可以整个网络中流通,主要是燃料Gas的作用,每产生一笔交易就会消耗一些 XRP;其二是引入网关(Gateway)系统,它类似于货币兑换机构,允许人们把法定货币注入、抽离Ripple网络,并可充当借、贷双方的桥梁。

Ripple引入了一个共识机制RPCA,通过特殊节点的投票,在很短的时间内就能够对交易进行验证和确认。Ripple客户端不需要下载区块链,它在普通节点上舍弃掉已经验证过的总帐本链,只保留最近的已验证总帐本和一个指向历史总帐本的链接,因而同步和下载总帐本的工作量很小。

Ripple的作用并不仅仅只负责清算货币兑换,它可以是各种虚拟货币、数字资产或任意一种有价值的东西。

Ripple的开源地址是:https://github.com/ripple/rippled,他的核心技术框架采用C++语言开发,TPS<1000。

七、     未来币NXT

未来币(Nxt、Nextcoin)是第二代去中心化虚拟货币,它使用全新的代码编写,不是比特币的山寨币。它第一个采用100%的股权证明POS算法,有资产交易、任意消息、去中心化域名、帐户租赁等多种功能,部分实现了透明锻造功能。

Nxt是且是第一个100%的股权证明机制的电子货币,Nxt不再通过消耗大量的资源“挖矿”产生新货币,而是通过现有账户的余额去“锻造”区块,并给与成功“锻造”区块的账户交易费用奖励。

Nxt具有一个非常灵活的特性,称为“透明锻造”。这一机制使得每一个用户客户端可以自动决定哪个服务器节点能够产生下一个区块。这使得客户端可以直接将交易发送到这个节点,从而使得交易的时间达到最短。实时和高优先级的交易可以通过支付额外的费用来被优先处理。

Nxt区块链2.0已经在讨论和计划实施中了,其核心思路就是要通过主链(Main Chain)和子链(Child Chain)的这种架构来增加Nxt区块链的可扩展性和可删减性,从而解决长期存在的区块链膨胀等问题;

Nxt的开源地址是:https://bitbucket.org/JeanLucPicard/nxt/overview,他的核心技术框架采用Java语言开发,TPS<1000。

八、其他

此外,还有几个区块链技术体系也介绍一下:

英特尔的锯齿湖(Sawtooth Lake),目前是用于建造、部署和运行分布式账本的高度模块化平台,重点领域在数字资产,在锯齿湖的数据模型和交易事务语言中,是由称为“transaction family”的体系来实现的, 給用户可以有开箱即用的功能齐全的市场数字资产管理体系。采用PoET和Quorum Voting两种共识算法,框架核心开发语言Python,开源地址为https://github.com/intelledger

布比区块链,目前采用的是对联盟链内定向开源,共识算法采用自研发的Pool验证池,可以集成Byzantine Paxos、Byzantine、Raft等商用共识算法,实现免Gas费用的秒级共识验证,框架核心开发语言是C++,应用场景比较广泛。

小蚁区块链,开源地址为https://github.com/antshares/antshares,采用改进的拜占庭容错算法-dBFT共识算法,支持智能合约,目前重点领域在数字资产应用,框架核心开发语言C#。

最后,汇总一下几大主流开源技术的比较。

名称

公识算法

适合场景

开发语言

智能合约

TPS

比特币1.0

POW

公链

C++

7

以太坊ETH 1.0

POW

公链/联盟链

GO

25

IBM HyperLedger fabric

PBFT为主

联盟链

GO

100K

比特股BitShare

DPos

联盟链

C++

500

公证通Factom

Factom自有共识机制,类Pos

公链/联盟链

C++

27

瑞波Ripple

RPCA

公链/联盟链

C++

1000

未来币NXT

Pos

公链/联盟链

Java

1000

*附注[共识算法解释]:

共识机制是区块链技术的关键点。共识机制的核心是在分布式网络中,利用一种规则(算法)来保证全网对于Block的创建是一致的,下面是主要的共识算法。

1、Pow工作量证明,就是大家熟悉的挖矿,通过与或运算,计算出一个满足规则的随机数,即获得本次记账权,发出本轮需要记录的数据,全网其它节点验证后一起存储;

2、Pos权益证明,Pow的一种升级共识机制;根据每个节点所占代币的比例和时间;等比例的降低挖矿难度,从而加快找随机数的速度。

3、DPos股份授权证明机制,类似于董事会投票,持币者投出一定数量的节点,代理他们进行验证和记账。

4、Pool验证池,由布比构建,基于传统的分布式一致性技术,加上数据验证机制;是目前行业链大范围在使用的共识机制

5、PoET(Proof ofElapsed Time),也就是‘消逝时间量证明’,它是由英特尔构建在可信执行环境的一种彩票协议。

6、QuorumVoting,属于Quorum拜占庭协议,仲裁投票算法,它采用了瑞波和恒星的共识协议,用来解决需立即交易定局的需求。”

7、Casper,以太坊社区提出的正在研发中的类POS共识协议。Casper的基本思路是,任何人抵押足够多的以太币到系统中就可以成为矿工参与到挖矿过程。共识算法要求所有的矿工诚实工作,如果一个矿工有意破坏,不遵守协议,系统就会对矿工做出惩罚:没收之前抵押的以太币。有人把Casper这样的挖矿机制称为“虚拟挖矿”。

8、PBFT(PracticalByzantine Fault Tolerance)算法,拜占庭容错算法,属于状态机拜占庭协议,IBM HyperLedger fabric实现和推荐的共识算法,采取一个节点一票的方案确定记账结果,少数服从多数投票,性能较好,主要用于联盟链。

使用perl 查找str序列

没啥说的,直接上代码

#!/usr/bin/perl -w
use strict;
use Bio::SeqIO;
#use Bio::Tools::TandemRepeatsFinder;
#Bio perl 需要事先安装
#安装过程如下,以ubuntu系统以为
# 1、安装cpanm 
#		wget http://xrl.us/cpanm -O /usr/bin/cpanm;
#		chmod +x /usr/bin/cpanm
# 2、安装Bio::perl
#	cpanm --mirror http://mirrors.163.com/cpan --mirror-only Bio::Perl
sub found_str{
	my %STRS;
	my $seqio_obj = Bio::SeqIO->new(-file => $_[0], -format => "fasta" );
	while (my $seq_obj = $seqio_obj->next_seq ) {
		my @agcts=split('',$seq_obj->seq); #将记录转换成字符数组
		my $agct_length= length $seq_obj->seq;
		my $start_index=0;
		for(my $j=$start_index;$j<$agct_length-1;$j=$start_index){
			#从序列数组最左边的元素开始搜索str串,直到序列数组结束
			my @end_indexs=(0,0,0,0,0);
			#记录本次搜索过程中找到的中止下标,由于str的周期为2-6,共5个周期,
			#故需要一个长度为5的数组,来记录当周期分别2、3、4、5、6时的中止下标
			my @repeated_times=(0,0,0,0,0); #记录当周期分别2、3、4、5、6时的重复周期数
			for(my $i=2;$i<=6;$i=$i+1){ #分别搜索当周期数为2、3、4、5、6时的str 长度与周期数
				my $breaks=0;
				for(my $j=$start_index;$j<$agct_length-1;$j=$j+$i){
					my $k;
					for($k=0;$k<$i;$k++){
					#比较一个周期内的全部元素,只有当一个周期的内全部元素相同时,才能算完整的重复了一个周期
						if($j+$k+$i>=$agct_length-1 || ($agcts[$j+$k]  ne $agcts[$j+$k+$i])){
							$breaks=1;
							last;
						}
					}
					if($breaks!=1){
						$repeated_times[$i-2]=$repeated_times[$i-2]+1;
						$end_indexs[$i-2]=$j+$k+$i;
					}else{
						last;
					}
				}
			}
			my $max_end_index=0;
			my $max_repeat_peroid=0;
			#找出本次搜索到的最长STR串
			for(my $i=2;$i<=6;$i=$i+1){
				if($end_indexs[$i-2]>$max_end_index){
					$max_end_index=$end_indexs[$i-2];
					$max_repeat_peroid=$i;
				}
			}
			if($max_repeat_peroid!=0 and $start_index>8 and $max_end_index+9< $agct_length and $repeated_times[$max_repeat_peroid-2]+1 >5){
				#本次搜索到了STR 串,将找到的STR串放入最终结果
				#本次搜索到了STR 串,右移下标 STR长度
				my $repeated_times = $repeated_times[$max_repeat_peroid-2]+1;
				my $start_bp = substr($seq_obj->seq,$start_index-8,8);
				my $repeated_element = substr($seq_obj->seq,$start_index,$max_repeat_peroid);
				my $end_bp = substr($seq_obj->seq,$max_end_index,8);
				my $str = "$start_bp\_$repeated_element\_$end_bp";				
				if( exists $STRS{$str}) {
					push @{$STRS{$str}}, $repeated_times[$max_repeat_peroid-2]+1;
				} else {
					my @nums=($repeated_times[$max_repeat_peroid-2]+1);
					$STRS{$str}=\@nums;
				}
				$start_index=$max_end_index+1;	
			}else{
				#本次搜索没有找到STR串,则右移下标
				$start_index=$start_index+1;
			}
		}
	}
	open(OUT,">test3.fasta.ssr.result");
	select OUT;
	print ("need_seq\tfind_cishu\tmeicichongfucishu\n");
	foreach my $key (keys %STRS){
		my $count = @{$STRS{$key}};
		print ($key,"	",$count ,"	");
		foreach my $num (@{$STRS{$key}}){
			print ($num,";");
		}
		print ("\n");
	}
}
found_str("test3.fasta");